• Home
  • Random
  • Nearby
  • Log in
  • Settings
Donate Now If Wikipedia is useful to you, please give today.
  • About Wikipedia
  • Disclaimers
Wikipedia

Template:Stacked bar/sandbox

  • Template
  • Talk
  • Language
  • Watch
  • Edit
< Template:Stacked bar
This is the template sandbox page for Template:Stacked bar (diff).
See also the companion subpage for test cases.
Template documentation[view] [edit] [history] [purge]
CSSThis template uses TemplateStyles:
  • Template:Stacked bar/styles.css (sandbox)

Usage

edit

Makes a horizontal stacked chart of up to 12 counts (plus a gray bar if the total is greater than the sum of the 12). If no total is supplied, defaults to 100 (for percentages). By default, uses nice rainbow of colors that don't correspond to reserved article class or importance colors, but colors can be customized.

Article counts may be automatically calculated with the {{PAGESINCATEGORY}} magic word, e.g. {{PAGESINCATEGORY:FA-Class Square Enix articles|R}}

  • A# variables: Amounts. Given as any plain number. No units permitted.
  • T# variables: Optional titles. If no title is wanted, leave completely blank. (A &nbsp; or similar is not helpful.)
  • C# variables: Optional colour values as any valid CSS colour. Defaults to a rainbow-type progression
  • Total Optional total amount. Given as any plain number. No units permitted. Defaults to 100.
  • height Optional height of the bar. Given as a CSS length (px recommended). Defaults to 10.
  • vertical_caption: If set to yes/true, have the labels use vertical text. If set to lean, tilts the text at an angle.
  • caption_height: If the captions are vertical, their height is limited to this. Given as a CSS length, e.g. 8em or 200px.
  • hover-pc: Display percentages on hover, via title-text.
TemplateData
This is the TemplateData for this template used by TemplateWizard, VisualEditor and other tools. See a monthly parameter usage report for Template:Stacked bar in articles based on its TemplateData.

TemplateData for Stacked bar

Makes a horizontal stacked chart of up to 12 counts (plus a gray bar if the total is greater than the sum of the 12). If no total is supplied, defaults to 100 (for percentages). By default, uses nice rainbow of colors that don't correspond to reserved article class or importance colors, but colors can be customized. Article counts may be automatically calculated with the {{PAGESINCATEGORY}} magic word, e.g. {{PAGESINCATEGORY:FA-Class Square Enix articles|R}} • A# variables: Amounts. Given as any plain number. No units permitted. • T# variables: Optional titles. If no title is wanted, leave completely blank. (An &nbsp; or similar is not helpful. • C# variables: Optional colour values as any valid CSS colour. Defaults to a rainbow-type progression

Template parameters[Edit template data]

This template has custom formatting.

ParameterDescriptionTypeStatus
Vertical captionvertical_caption

If set to yes/true, have the labels use vertical text.

Booleanoptional
Caption height limitcaption_height

If the captions are vertical, their height is limited to this. Given as a CSS length.

Default
8em
Stringoptional
Hover texthover-pc

If present, hovering the mouse over a bar segment shows the percentage of the total. Only works on pc.

Booleanoptional
Bar heightheight

Height of the bar as a CSS length (px recommended).

Default
Default is 10px; this is as thin as you would want to go.
Stringoptional
Total amountTotal

Total amount that the bars sum to. Should be a number with no units.

Default
Defaults to 100 so that percentages can be used as the amounts.
Numberoptional
Text 1T1

Label of this item

Linesuggested
Amount 1A1

Amount of this item (plain number)

Numberrequired
Text 2T2

Label of this item

Linesuggested
Amount 2A2

Amount of this item (plain number)

Numberrequired
Text 3T3

Label of this item

Linesuggested
Amount 3A3

Amount of this item (plain number)

Numbersuggested
Text 4T4

Label of this item

Lineoptional
Amount 4A4

Amount of this item (plain number)

Numberoptional
Text 5T5

Label of this item

Lineoptional
Amount 5A5

Amount of this item (plain number)

Numberoptional
Text 6T6

Label of this item

Lineoptional
Amount 6A6

Amount of this item (plain number)

Numberoptional
Text 7T7

Label of this item

Lineoptional
Amount 7A7

Amount of this item (plain number)

Numberoptional
Text 8T8

Label of this item

Lineoptional
Amount 8A8

Amount of this item (plain number)

Numberoptional
Text 9T9

Label of this item

Lineoptional
Amount 9A9

Amount of this item (plain number)

Numberoptional
Text 10T10

Label of this item

Lineoptional
Amount 10A10

Amount of this item (plain number)

Numberoptional
Text 11T11

Label of this item

Lineoptional
Amount 11A11

Amount of this item (plain number)

Numberoptional
Text 12T12

Label of this item

Lineoptional
Amount 12A12

Amount of this item (plain number)

Numberoptional
Colour 1C1

CSS colour of this item

Stringoptional
Colour 2C2

CSS colour of this item

Stringoptional
Colour 3C3

CSS colour of this item

Stringoptional
Colour 4C4

CSS colour of this item

Stringoptional
Colour 5C5

CSS colour of this item

Stringoptional
Colour 6C6

CSS colour of this item

Stringoptional
Colour 7C7

CSS colour of this item

Stringoptional
Colour 8C8

CSS colour of this item

Stringoptional
Colour 9C9

CSS colour of this item

Stringoptional
Colour 10C10

CSS colour of this item

Stringoptional
Colour 11C11

CSS colour of this item

Stringoptional
Colour 12C12

CSS colour of this item

Stringoptional

Examples

edit
Video game good articles by arbitrary category
{{Stacked bar|A1=833|T1=Video games |A2=33|T2=Series |A3=94|T3=Characters |A4=99|T4=Development |A5=71|T5=Music |A6=29|T6=Media |A7=36|T7=Etc|C7=Black |Total=1195}}
Note that if the width of the bar section is narrower than the width of the labels, then the labels push each other out of the way, harming readability. The final section has also been given a specified color, while the rest are left at defaults.
Video games
Series
Characters
Development
Music
Media
Etc




Video game good articles with vertical text
This is slightly harder to read, but will allow all but the narrowest categories to line up properly.
{{Stacked bar|vertical_caption=yes|A1=833|T1=Video games |A2=33|T2=Series |A3=94|T3=Characters |A4=99|T4=Development |A5=71|T5=Music |A6=29|T6=Media |A7=36|T7=Etc|C7=Black |Total=1195}}
Video games
Series
Characters
Development
Music
Media
Etc




Number of video game articles in the 70s and earlier by year with a higher total than the sum
Note that some labels are abbreviated to avoid displacement. Note also the gray area at the end, as the sum of the categories is less than the "Total" number.
{{Stacked bar|A1=13|T1=<1970s |A2=5|T2=71 |A3=4|T3=72 |A4=8|T4=73 |A5=7|T5=74 |A6=16|T6=1975 |A7=23|T7=1976 |A8=24|T8=1977 |A9=37|T9=1978 |A10=54|T10=1979 |Total=200}}
<1970s
71
72
73
74
1975
1976
1977
1978
1979



Video game good articles by year
Note that some labels are skipped to avoid displacement
{{Stacked bar|A1=11|T1= |A2=17|T2= |A3=37|T3=<1985 |A4=83|T4=85–89 |A5=129|T5=1990–94 |A6=179|T6=1995–99 |A7=198|T7=2000–04 |A8=221|T8=2005–09 |A9=221|T9=2010–14 |A10=125|T10=2015–19 |A11=9|T11= |Total=1230}}
<1985
85–89
1990–94
1995–99
2000–04
2005–09
2010–14
2015–19



Leaning labels (vertical_caption=lean)
Leaning labels, with a thicker bar, placed inside of an image frame. Note the line break in the final caption.
Intel
None
Red Hat
Linaro
Unknown
IBM
Consultants
Samsung
SUSE
Google
other
companies


{{Stacked bar | height=18px | vertical_caption=lean |T1=[[Intel]]|A1=13.1|C1=#0072c6 |T2=''None''|A2=8.2|C2=#ccc |T3=[[Red Hat]]|A3=7.2|C3=#e00 |T4=[[Linaro]]|A4=5.6|C4=#96c72e |T5=''Unknown''|A5=4.1|C5=#ccc |T6=[[IBM]]|A6=4.1|C6=#1870c0 |T7=''Consultants''|A7=3.3|C7=#ccc |T8=[[Samsung]]|A8=3.2|C8=#004da4 |T9=SUSE|A9=3|C9=#30BA78 |T10=Google|A10=3|C10=#fbbc05 |T11=''other<br/>companies''|A11=45.2|C11=#eee}}[1]
Hover-pc
Title text present when hovering the mouse over the bar segments. Does not work on mobile.
{{Stacked bar|A1=11|T1= |A2=17|T2= |A3=37|T3=<1985 |A4=83|T4=85–89 |A5=129|T5=1990–94 |A6=179|T6=1995–99 |A7=198|T7=2000–04 |A8=221|T8=2005–09 |A9=221|T9=2010–14 |A10=125|T10=2015–19 |A11=9|T11= |Total=1230 |hover-pc=yes}}
<1985
85–89
1990–94
1995–99
2000–04
2005–09
2010–14
2015–19



See also

edit
  • {{Progression rainbow}}, which has no option for captions and always uses article class colors
  • v
  • t
  • e
Progress templates
General progress templates
  • {{Progress bar}}
  • {{Progression}}
  • {{Composition bar}}
  • {{Composition bar/advanced}}
  • {{Composition bar compact}}
  • {{Composition histogram}}
  • {{Percentage bar}}
  • {{Number and percent}}
  • {{Progress meter}}
  • {{Percentile}}
  • {{Stacked bar}}
Specific-use templates
  • {{Backlog progress bar}}
  • {{Progress box}}
  • {{Progression rainbow}}
  • {{WikiProject assessment progression}}
  • {{Article length bar}}
  • Category
  • List (partial)
  • v
  • t
  • e
Graph, chart and plot templates
Many types
  • {{#chart}}
  • {{Graph:Chart}}
  • Module:Chart
Graph Extension
  • {{Graph:Chart}}
  • {{Graph:Lines}}
  • {{Graph:Stacked}}
  • {{Map with marks}}
Bar
  • {{Bar chart}}
  • {{Bar box}}
  • {{Bar stacked}}
  • Module:Bar
  • {{Data bars}}
Line
  • {{Graph:Lines}}
Scatter plot
  • {{Dot chart}}
Pie chart
  • {{Pie chart}}
Tree
  • {{Tree chart}}
  • {{Ahnentafel}}
  • {{Clade}}
Stacked
  • {{Stacked bar}}
Cartogram
  • {{Graph:Map}}
  • {{Global Heat Maps by Year}}
Color legends
  • {{Legend}}
  • {{Legend-line}}
  • {{BrewerColorLegends}}
The above documentation is transcluded from Template:Stacked bar/doc. (edit | history)
Editors can experiment in this template's sandbox (edit | diff) and testcases (edit) pages.
Add categories to the /doc subpage. Subpages of this template.
Retrieved from "https://en.wikipedia.org/w/index.php?title=Template:Stacked_bar/sandbox&oldid=1275957766"
Last edited on 16 February 2025, at 01:49

Languages

      This page is not available in other languages.

      Wikipedia
      • Wikimedia Foundation
      • Powered by MediaWiki
      • This page was last edited on 16 February 2025, at 01:49 (UTC).
      • Content is available under CC BY-SA 4.0 unless otherwise noted.
      • Privacy policy
      • About Wikipedia
      • Disclaimers
      • Contact Wikipedia
      • Code of Conduct
      • Developers
      • Statistics
      • Cookie statement
      • Terms of Use
      • Desktop