Jump to content

Template talk:Pie chart

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

Background color

[edit]

Since the pie chart is shown in a thumb frame, which has #f9f9f9 as the background color, shouldn't File:Circle frame.svg have the same background color? EdokterTalk 12:08, 16 December 2010 (UTC)[reply]

Since this template is the only one using the image, I modified the image. EdokterTalk 12:20, 16 December 2010 (UTC)[reply]

Vertical start point?

[edit]

Is it possible to have the start-point re-set to 0° instead of 90°? I find this almost useful as it is, but not quite. FanRed XN | talk 10:32, 30 August 2011 (UTC)[reply]

Zoom

[edit]

If there anyway to widen the chart? Say with a 400px parameter, for example, or a zoom=200 (percent), where the current size is zoom=100? --RoyGoldsmith (talk) 16:01, 8 August 2012 (UTC)[reply]

Text wrap

[edit]

I may be doing something wrong, but when I've tested this template it doesn't seem to allow the text to wrap around. This is obviously a problem when the objective is to embed the chart in the text, so any advice would be appreciated. CanadianJudoka (talk) 22:14, 8 September 2012 (UTC)[reply]

It's used at Breast cancer awareness#Risks_of_over-awareness, and it seems to text-wrap properly there. Can you give an example? WhatamIdoing (talk) 19:37, 29 April 2013 (UTC)[reply]

"Scaling up" when total does not = 100

[edit]

It would be nice if the chart automatically "scaled up" when the total does not quite equal 100% due to rounding by adding the same amount (%wise) to each portion. --JFH (talk) 16:34, 27 April 2013 (UTC)[reply]

Not possible I'm afraid. The template uses a fixed formula where the total needs to be 100, becuase those values are directly translated to CSS. Perhaps a Lua solution could be much more flexible. Edokter (talk) — 18:39, 27 April 2013 (UTC)[reply]

Broken on mobile browsers; Not backwards compatible

[edit]

See [1]. There should be support in m:Extension:EasyTimeline for this. We aren't even showing SVG's inline because we fear the client has no support. And SVG is more widely supported than CSS3. Wikipedia shouldn't be a CSS3 playground. --Ysangkok (talk) 11:36, 1 May 2013 (UTC)[reply]

Re:Mobile device. I used this template and noticed it works on mobile device when in WP "desktop view" but not in "mobile view". I.am.a.qwerty (talk) 13:17, 8 May 2014 (UTC)[reply]
Resolved now, see WP:VPT#Template:Pie chart and the mobile version. 109.76.215.183 (talk) 11:24, 21 May 2014 (UTC)[reply]

iw cy

[edit]

Tried using this pie chart on the Welsh Wiki, but to no avail! Can some one please take a look here. As you can see, there's a flaw somewhere. It works fine on the corresponding Wiki-en. Many thanks. Llywelyn2000 (talk) 07:36, 3 August 2013 (UTC)[reply]

Limit of 15 instead of 10 slices

[edit]

Added PV capacity by country in 2014 (clustered by region)

  China & Taiwan (28.3%)
  Japan (25.1%)
  South Korea (2.3%)
  Thailand (1.2%)
  India (1.6%)
  Australia (2.4%)
  United States (16.0%)
  Canada (1.3%)
  Chile (0.9%)
  Germany (4.9%)
  Italy (1.0%)
  United Kingdom (5.9%)
  Rest of Europe (5.6%)
  South Africa (2.1%)
  Rest of the World (1.4%)

I amended the first sentence of the template documentation that states "The labels and values of up to ten slices may be specified. All the parameters for six slices are included below; to include more slices, copy the code for one of the others, changing the digit at the end of each parameter name." In fact, pie-chart works with up to 15 different items, not 10. See example. Thought that's rather important to mention in section "Limitations". Of course, an increase to 20 slices would be appreciated;) – Cheers, Rfassbind -talk 14:04, 27 April 2015 (UTC)[reply]

New extension available: GRAPH

[edit]

See example and details on [Wikitech-l] GRAPH extension is now live everywhere!. Helder 12:24, 6 May 2015 (UTC)[reply]

Extension:Graph based template created

[edit]

Template:PieChart provides a way to add a pie chart using extension:graph. The vega specification is in the template. You can add a pie chart now with

{{PieChart|title="Fruits"|radius=125|values=
  [ {"x":"Peaches", "y":100}, {"x":"Plums", "y":32}, {"x":"Blueberries", "y":80}, {"x":"Strawberries", "y":46}, {"x":"Bananes", "y":41} ]
}}
{{Graph:PieChart|legend=Fruits|radius=125
| rangeliteral= ["red", "green","red","green","red","green","red","green","red","green"]
| values= [
      {"x":"perziken", "y":10},
      {"x":"pruimen", "y":10},
      {"x":"bessen", "y":10},
      {"x":"aardbeien", "y":10},
      {"x":"bananen", "y":10},
      {"x":"peach", "y":10},
      {"x":"plum", "y":10},
      {"x":"blueberries", "y":10},
      {"x":"strawberries", "y":10},
      {"x":"bananas", "y":10}
    ] 
}}
Ad Huikeshoven, there are over 700 transclusions of this template, so clearly people won't switch easily. Instead, I think this template should remain, but it should be modified to use the graph extension, thus keeping everyone happy :). The documentation should probably mention that there is another template available if needed, with more functionality. --Yurik (talk) 18:37, 29 December 2015 (UTC)[reply]
Thanks Yurik. Actually, I like the template style of Template:Pie chart better than of Graph:PieChart. There is some work to be done to create the Template:Pie chart legend style in combination with the graph extension pie chart. Including wiki links in legend text might be a challenge. Ad Huikeshoven (talk) 11:40, 31 December 2015 (UTC)[reply]

Sortable caption?

[edit]

I wonder if the caption could be made sortable, by converting it to a table, if an option is selected. In the pie chart of numbers of speakers in groups Varieties of Chinese, the Chinese varieties are sorted in the same order as they are mentioned in the text (perhaps from north to south?). As a result, you can't see at a glance which varieties are spoken more than others.

It would be nice if the template could generate a table like the one below, which would allow the entries in the pie chart to be ranked by name or value. — Eru·tuon 01:15, 18 September 2016 (UTC)[reply]



(70.9)
  Jin
(3.8)
  Wu
(6.5)
(0.4)
  Gan
(1.7)
  Xiang
(3.0)
  Min
(6.0)
  Hakka
(2.5)
  Yue
(5.0)
(0.2)
This seems an overly complex solution to a minute problem that will just disappear if you order by size to begin with. You don't need to follow the order of the prose, since it's not a tabular lineup of elements, so people will already have difficulty matching prose to the pie chart legend. —TheDJ (talkcontribs) 05:31, 27 October 2016 (UTC)[reply]

Histogram

[edit]

Can you make one of these templates for histograms with variable bin widths? So you specify the bin boundaries and the amount in each bin, and it plots so that the area of the box matches the amount in that bin.

Similar to https://en.wikipedia.org/wiki/File:Travel_time_histogram_total_n_Stata.png or https://commons.wikimedia.org/wiki/File:AkkaTechnologies_-_histogramme_des_ages_employes_2013.png

It's not easy to make these charts with typical plotting tools, and a lot of times this data is shown instead using pie charts, but pie charts are an inappropriate choice. — Preceding unsigned comment added by 71.167.64.138 (talk) 17:57, 17 December 2016 (UTC)[reply]

Square

[edit]

Pie chart is square on mobile browser on sino-Tibetan. Pi day joke? Samples render ok on this page. Lollipop (talk) 02:44, 10 March 2018 (UTC) Lollipop (talk) 02:44, 10 March 2018 (UTC)[reply]

Conflict with Blackscreen gadget

[edit]

This template conflicts with the blackscreen gadget. There is a thread about this at Wikipedia:Village pump (technical)#Deformed pie chart. DuncanHill (talk) 13:37, 4 June 2018 (UTC)[reply]

This is still a problem on the mobile app when using an Android phone in Dark Mode. See Wikipedia:Village pump (technical)#Return of the deformed pie chart. -Apocheir (talk) 23:04, 25 September 2021 (UTC)[reply]

It's still a problem on desktop too. DuncanHill (talk) 23:12, 25 September 2021 (UTC)[reply]
Note, as reported on reddit, this is still an issue. On the corresponding Phabricator ticket, it was suggested that the problem could be fixed using the CSS background-color: initial. Opencooper (talk) 01:11, 19 July 2022 (UTC)[reply]
I applied that suggested change. — The Earwig (talk) 05:13, 19 July 2022 (UTC)[reply]

Notice of discussion regarding this template

[edit]

This template, and whether or not to change the display of the output, is being discussed here. Primefac (talk) 14:05, 7 September 2018 (UTC)[reply]

Remove IE6 support

[edit]

Internet Explorer 6 only supports SSL, not TLS, whereas Wikimedia servers only support TLS, not SSL, over HTTPS connections. Wikimedia's use of HSTS means that it is not possible to view Wikipedia with an insecure HTTP-only connection, and the lack of overlap in protocol support between IE6 and the WMF means that attempting to view a WMF wiki with IE6 now results in a protocol error (and has for at least a year). Because of this, IE6 support in this template is now an unnecessary bit of cruft that should be removed. I am aware of the .transborder class in MediaWiki:Common.css, and accompanying documentation on Template:Pie chart/doc, but I don't know if any code specifically in this template is dedicated to IE6 support. All of this should now be removed. ディノ千?!? · ☎ Dinoguy1000 04:49, 20 September 2018 (UTC)[reply]

Note: transborder class is also used in Template:Twitter Bird and Module:Plotter. -- WOSlinker (talk) 08:21, 20 September 2018 (UTC)[reply]
I could only find 4 uses of the class (Template:Twitter Bird, Module:Plotter, Module:Chart & Template:Pie chart/slice), so I've converted them all to inline styles instead rather than trying to workout if it all looks ok without that style. It can now be removed from Common.css. I'll wait a few days and then make the request. -- WOSlinker (talk) 18:37, 7 October 2018 (UTC)[reply]

colors

[edit]

To editor Guarapiranga: The changes you made tilted the entire color-scheme towards blue. As there was no consensus for this, I've reverted you. Per WP:BRD, please discuss. Chris Troutman (talk) 13:45, 10 November 2019 (UTC)[reply]

Yes, Chris troutman, I made the change in the spirit of WP:BRD. That colour scheme is the one adopted by {{graph}} and it's the D3 standard, recommended by Prof. Cynthia Brewer from Penn State University. There's a science and a method to it, which the current scheme seems to have none of. Guarapiranga (talk) 21:12, 10 November 2019 (UTC)[reply]
You could organize an RfC to establish wider consensus, but I don't like your color scheme; I don't care that there's a method to it. Chris Troutman (talk) 21:29, 10 November 2019 (UTC)[reply]
@Guarapiranga: To be more specific, the first value and the second value are too close in hue and initial values seem to skew heavy to winter palette. I would want to see more contrast. Chris Troutman (talk) 00:51, 11 November 2019 (UTC)[reply]
Ok,  Done. Guarapiranga (talk) 05:59, 11 November 2019 (UTC)[reply]
Let's try that again…
Upon, Chris troutman's suggestion, I'm calling for comment on adopting the aforementioned colour scheme in this template. Guarapiranga (talk) 20:59, 11 November 2019 (UTC)[reply]

With the greatest respect to everyone involved so far, but we'd need extraordinarily good reasons to keep the previous scheme. It's downright abysmal: it relies heavily on hue differences, which means it's bad for colour-blind people (sequential colours are not always contrastive: for example, the first two colours look too similar for readers with protanopia), and it's bad for printing (all but two of the colours are indistinguishable in greyscale). Furthermore, its use of strong saturated primary colours is ugly (particularly jarring is the juxtaposition of strong green and red, which are the first two colours in the list and so the ones most likely to take up the largest neighbouring chunks of the pie).

The old colour scheme would have been OK in the early days of the internet, but we really should do better now. A colour scheme needs to be accessible, it needs to display acceptably in a wide range of environments and it needs to be aesthetically pleasing.

The only reason I could think of for sticking to the old scheme is the possibility that editors might have somehow relied on the the default colours being what they are: either for colour symbolism, or when referring to the chart colours in the text outside the chart. The first scenario is extremely unlikely given the template setup, but the second one is plausible. How likely is it that there will be references to the colours within article text? I've had a look at a random selection of 15 articles that use the template and I couldn't spot any obvious such mentions. (Tellingly, of these 15 articles, only 2 were using the default colours).

I'll restore Guarapiranga' changes. Of the colour palettes at [2] this is the one with the most robust contrast for sequential colours, so it's really good for this use. However, I would not object if any other suitable scheme is chosen instead. – Uanfala (talk) 00:21, 23 December 2019 (UTC)[reply]

  • Prefer change to Guarapiranga's or another scheme, since the ultrasaturated hues are indeed jarring, and since Uanfala seems to have thought this through most thoroughly, so I defer to them. Whatever was/is decided, please keep the documentation in sync with the actual template, since right now the documentation has the proposed change while the live template does not, and that's not an okay combo. {{u|Sdkb}}talk 03:32, 9 August 2020 (UTC)[reply]
    • Oh yeah, I was about to implement a change at the time, but then got distracted and never quite found the time afterwards. I'll get around to doing it at some point, but if anyone wants to beat me to it, by all means go ahead. The colour schemes in the link above will probably tick all the boxes, the only trick is to find the one that's got the best contrast (incl. in grayscale etc.) between neighbouring colours. – Uanfala (talk) 16:23, 16 August 2020 (UTC)[reply]
      Uanfala, I'll leave it to you, since I wouldn't want to mess anything up. Thanks for your insights/work on this! {{u|Sdkb}}talk 19:25, 16 August 2020 (UTC)[reply]

 You are invited to join the discussion at Wikipedia:Village pump (technical) § Pie chart troubles. {{u|Sdkb}}talk 08:21, 9 August 2020 (UTC)[reply]

@Jackmcbarn, as a follow-up to this, it looks like whatever needed to happen on the back end has now happened, so your prototype at the VPT discussion now works. Would the next step be to convert this template to use the graph extension? Someone brought up troubles in the #technical Discord channel earlier, so this might solve multiple concerns. Courtesy ping @Izno from Discord. {{u|Sdkb}}talk 17:53, 4 July 2021 (UTC)[reply]
pls no ask Seddon instead (<3). Izno (talk) 17:56, 4 July 2021 (UTC)[reply]

BrewerColorLegends

[edit]

Dear creators of templates, today I was working in my sandbox and I wanted to apply something like a color list. After a quick search in list of templates I found BrewerColorLegends. How can I add them to my pie chart, is it even possible? If not, is planned or is there a substitution for this kind of problem? With Regards, --A09090091 (talk) 09:53, 2 December 2020 (UTC)[reply]

@A09090091: if I understand you correctly, you're trying to customize the color scheme on a pie chart so that it will follow a ColorBrewer palette? To do that, you can use |colorN=hex code (where N is the label number and the hex code is e.g. #000000). The documentation here explains most of it, although it's a little misaligned with the template's current behavior. Uanfala, Guarapiranga, myself, and others are also having a discussion above about making that change to the template itself so that it'd be the default. Cheers, {{u|Sdkb}}talk 10:35, 2 December 2020 (UTC)[reply]
@Sdkb:I was so used to matplotlib and seaborn in Python frameworks. Must say it was simpler and as I got stopped by this I immediately asked for help. Thanks once again. You helped me so much. --A09090091 (talk) 11:59, 2 December 2020 (UTC)[reply]

Obtrusive white line at 180 and 270 degrees on Firefox (Desktop)

[edit]

I am observing a white line at 180 and 270 degrees overlapping whatever color segment that exists,on Firefox browser 113.0.1 (64 bit) on Ubuntu 18.04, while the pie chart is proper on Google chrome Version 107.0.5304.87 (Official Build) (64-bit). (Please see the template page using Firefox browser.) Android version of Firefox is also displaying it properly. Is there any fix possible to the code? Arjunaraoc (talk) 01:36, 14 May 2023 (UTC)[reply]

Just popping in to say that I'm also experiencing this. Tried restarting my browser, updating Firefox, and restarting my laptop, but the lines remain. Dragon401k (talk) 04:29, 15 May 2023 (UTC)[reply]
@Dragon401k, I noticed that these lines some times do not appear, so the problem is intermittent. Arjunaraoc (talk) 01:29, 3 June 2023 (UTC)[reply]

Incorrect colors (at least) on Safari in iOS

[edit]

Some people wrote about incorrect pie chart colors in the article Oulu#Languages. I noticed they wrote the comments with a mobile phone, so I checked the article on Safari 17.3 in iOS 17.3, and I noticed the same color issue. Here's a comparison of the correct and incorrect colors:

Hidden

Population by mother tongue (2022)

  Finnish (94.5%)
  Russian (0.6%)
  Arabic (0.5%)
  English (0.4%)
  Chinese (0.3%)
  Farsi (0.2%)
  Swedish (0.2%)
  Other (3.3%)

So, any idea what's causing this? --JAAqqO (talk) 17:02, 10 February 2024 (UTC)[reply]

I'm able to reproduce this bug in desktop Safari; as I make the page smaller, at some point the two dark blue divs that cover the right and bottom halves of the pie chart disappear. It's the same point that the table above the chart in the previous section starts to overflow its container. (1 2). On its surface, feels like maybe a Safari rendering bug, but haven't figured it out any further yet. — The Earwig (talk) 22:52, 18 February 2024 (UTC)[reply]
@JAAqqO: I've made a small tweak, a bit ugly, that should fix this. — The Earwig (talk) 00:06, 19 February 2024 (UTC)[reply]
Yes, that fixed it. Thank you. --JAAqqO (talk) 12:58, 19 February 2024 (UTC)[reply]

Default label placement on Pie chart

[edit]

Why do have label placement on the bottom by default? Can't it be move to left or right?

{{Pie chart
|thumb = right
|radius = 100
|footer = Source: [[Election Commission of India]]
|caption = '''Political parties' success rate on Pilibhit constituency'''
|value1  = 23.52
|value2  = 29.41
|value3  = 17.64
|value4  = 11.76
|value5  = 5.88
|label1  = [[Indian National Congress|INC]] (4 terms)
|label2  = [[Bharatiya Janata Party|BJP]] (5 terms)
|label3  = [[Praja Socialist Party|PSP]] (3 terms)
|label4  = [[Janata Dal|JD]] (2 terms)
|label5  = [[Janata Party|JP]] (1 term)
|color1  = {{party color|Indian National Congress}}
|color2  = {{party color|Bharatiya Janata Party}}
|color3  = {{party color|Praja Socialist Party}}
|color4  = {{party color|Janata Dal}}
|color5  = {{party color|Janata Party}}
| other  = yes
| other-label = [[Independent (politician)|IND]] (2 terms)
| other-color = {{party color|Independent (politician)}}
}}

Political parties' success rate on Pilibhit constituency

  INC (4 terms) (23.52%)
  BJP (5 terms) (29.41%)
  PSP (3 terms) (17.64%)
  JD (2 terms) (11.76%)
  JP (1 term) (5.88%)
  IND (2 terms) (11.79%)

Source: Election Commission of India

Exotica24 (talk) 19:30, 28 April 2024 (UTC)[reply]

You might want to try Template:Piechart. --Redrose64 🌹 (talk) 22:26, 28 April 2024 (UTC)[reply]