Difference between revisions of "Template:Brick chart/Bricks/sandbox"

From blackwiki
Jump to navigation Jump to search
imported>Wikid77
(created, as a sandbox version of Template:Brick_chart/Bricks, to test changes)
 
imported>Wikid77
(fixed to replace mod as "{c} - 10*floor( {c}/10 )" not rounded.)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
<noinclude>
+
<noinclude><!--
draws bricks for {{tl|Brick chart}}
+
-=============================================================================
</noinclude>{{#if:{{{count|0}}}>0|<div style="
+
-  Brick_chart/Bricks - Draw bricks for 1 count in {Brick_chart} numbers
 +
-=============================================================================
 +
--                        (see NOTES at bottom)
 +
-->
 +
</noinclude>{{
 +
#ifexpr:{{{count|0}}} > 0
 +
  |<!--show initial brick(s)--><div style="
 
   background:{{{color|silver}}};
 
   background:{{{color|silver}}};
 
   float:left;
 
   float:left;
   clear:{{#ifexpr:{{{offset|0}}} mod {{{stride|10}}}|none|left}};
+
   clear:{{#ifexpr:{{{offset|0}}} - {{{stride|10}}} *
   height:{{#expr:100/{{{stride|10}}}}}%;
+
        floor( ( {{{offset|0}}} )/{{{stride|10}}} ) > 0 |none|left}};
 +
   height:{{#expr:100/{{{stride|10}}} }}%;
 
   overflow:hidden;
 
   overflow:hidden;
   width:{{#expr:{{min|{{#expr:({{{stride|10}}} - {{{offset|0}}} mod {{{stride|10}}})}}|{{{count|0}}}}} * 100/{{{stride|10}}} }}%;
+
   width:{{#expr:
   ">&nbsp;</div>{{#ifexpr:{{{count|0}}} > {{min|{{#expr:({{{stride|10}}} - {{{offset|0}}} mod {{{stride|10}}})}}|{{{count|0}}}}}
+
    {{min|{{#expr: {{{stride|10}}} - ( {{{offset|0}}} - {{{stride|10}}} *
|<div style="
+
            floor( ( {{{offset|0}}} )/{{{stride|10}}} ) ) }}
  background:{{{color|grey}}};
+
        |{{{count|0}}}}} * 100/{{{stride|10}}} }}%;
  float:left;
+
   ">&nbsp;</div>{{
  clear:left;
+
  #ifexpr:{{{count|0}}} > {{min
  width:100%;
+
      |{{#expr: {{{stride|10}}} - ( {{{offset|0}}} - {{{stride|10}}} *
  overflow:hidden;
+
            floor( ( {{{offset|0}}} )/{{{stride|10}}} ) ) }}
  height:{{#expr:
+
      |{{{count|0}}} }}
  floor(({{{count|0}}}
+
    |<!--show full-line bricks--><div style="
  -{{min|{{#expr:({{{stride|10}}} - {{{offset|0}}} mod {{{stride|10}}})}}|{{{count|0}}}}}
+
    background:{{{color|grey}}};
  -(({{{count|0}}} + {{{offset|0}}}) mod {{{stride|10}}})
+
    float:left;
  )/{{{stride|10}}}) * 100/{{{stride|10}}} }}%;
+
    clear:left;
  ">&nbsp;</div>
+
    width:100%;
  {{#ifexpr:(({{{count|0}}} + {{{offset|0}}}) mod {{{stride|10}}})>0
+
    overflow:hidden;
  |<div style="
+
    height:{{#expr:
  background:{{{color|silver}}};
+
      floor( {{{count|0}}}
  float:left;
+
      - {{min
  clear:left;
+
            |{{#expr: {{{stride|10}}} - ( {{{offset|0}}} - {{{stride|10}}} *
  height:{{#expr:100/{{{stride|10}}}}}%;
+
                  floor( ( {{{offset|0}}} )/{{{stride|10}}} ) ) }}
  width:{{#expr:(({{{count|0}}} + {{{offset|0}}}) mod {{{stride|10}}}) * 100/{{{stride|10}}} }}%;
+
            |{{{count|0}}}}}
  ">&nbsp;</div>
+
      - ( {{{count|0}}}+{{{offset|0}}} - {{{stride|10}}} *
}}
+
          floor( ( {{{count|0}}}+{{{offset|0}}} )/{{{stride|10}}} )
}}
+
        ) ) }}%<!--
}}
+
    -->">&nbsp;</div>{{
 +
    #ifexpr: {{{count|0}}}+{{{offset|0}}} - {{{stride|10}}} *
 +
        floor( ( {{{count|0}}}+{{{offset|0}}} )/{{{stride|10}}} ) > 0
 +
      |<!--show final bricks (if any)--><div style="
 +
        background:{{{color|silver}}};
 +
        float:left;
 +
        clear:left;
 +
        overflow:hidden;
 +
        height:{{#expr:100/{{{stride|10}}} }}%;
 +
        width:{{#expr: ( {{{count|0}}}+{{{offset|0}}} - {{{stride|10}}} *
 +
          floor( ( {{{count|0}}}+{{{offset|0}}} )/{{{stride|10}}} ) )
 +
              * 100/{{{stride|10}}} }}%;<!--
 +
        -->">&nbsp;</div>
 +
    }}
 +
  }}
 +
}}<noinclude><!--
 +
----------------------------------------------------------------------------
 +
--NOTES
 +
--
 +
-- NOTE A1: This template draws 1-3 line segments for: the initial bricks,
 +
--      whole lines of middle bricks, and the final bricks (if any).
 +
--
 +
-- NOTE S2: For a line to be visible, there must be a non-breaking space,
 +
--      where the div-tag contains an "&nbsp;".
 +
--
 +
----------------------------------------------------------------------------
 +
-HISTORY
 +
-17Aug2009 Created to display brick chart using div-tag line segments.
 +
-17Sep2012 Put HISTORY comments to log major changes (not typos).
 +
-17Sep2012 Put NOTES comments to explain template operation & limits.
 +
-17Sep2012 Indented markup to show 3 nested if-structures.
 +
-17Sep2012 Fixed overlapped bars by full use of div-tag "overflow:hidden;".
 +
-17Sep2012 Added "overflow:hidden;" to 3rd line segment to match 1 & 2.
 +
-17Sep2012 Allowed decimals by replacing mod as: {c} - 10*floor( {c}/10 ).
 +
-->
 +
 
 +
The '''[[Template:Brick_chart/Bricks]]''' draws bricks for {{tl|Brick chart}}.
 +
 
 +
</noinclude>

Latest revision as of 23:20, 17 September 2012


The Template:Brick_chart/Bricks draws bricks for {{Brick chart}}.