Jump to content

Template talk:Graph:PieChart

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

Example usage:

Stacked pie

[edit]

A pie chart is a stacked bar chart in polar coordinates for a single category. Above an example of a stacked pie chart, that is with mutiple - here two - categories. The Vega specification can probably be optimized somehow. Any use within Wikipedia? Need for a separate template, or is this somehow to be included within the template? Ad Huikeshoven (talk) 22:19, 27 December 2015 (UTC)[reply]

Wow, this is pretty cool! One usage idea - it could be used for showing how distribution of something has changed with time, e.g. each ring represents a year. As for Vega itself - I think it would be better to use "group" mark that wraps the arc (similar to this or this examples). With groups, it should even be possible to integrate it into the current template, or to build a separate template to keep things simple. --Yurik (talk) 04:08, 28 December 2015 (UTC)[reply]
group, facet and groupby aren't really straightforward, but here you go:

<graph>{ "version": 2, "width": 150, "height": 150, "legends": [{"title": "Fruits","fill": "color"}], "data": [ { "name": "table", "values": [ {"year": "2010","category": "Berries","value": 10}, {"year": "2010","category": "Plums","value": 12}, {"year": "2010","category": "Oranges","value": 3}, {"year": "2010","category": "Apples","value": 7}, {"year": "2015","category": "Berries","value": 8}, {"year": "2015","category": "Plums","value": 4}, {"year": "2015","category": "Oranges","value": 5}, {"year": "2015","category": "Apples","value": 9} ] } ], "scales": [ { "name": "radius", "type": "ordinal", "domain": {"data": "table","field": "year"}, "range": "height" }, { "name": "color", "range": "category20", "domain": {"data": "table","field": "category"}, "type": "ordinal" } ], "marks": [ { "type": "group", "from": { "data": "table", "transform": [{"type": "facet","groupby": ["year"]}] }, "marks": [ { "name": "stacked pie", "type": "arc", "from": {"transform": [{"field": "value","type": "pie"}]}, "properties": { "enter": { "innerRadius": { "scale": "radius", "field": "year", "offset": 25 }, "stroke": {"value": "white"}, "startAngle": {"field": "layout_start"}, "outerRadius": { "scale": "radius", "field": "year", "offset": 75 }, "endAngle": {"field": "layout_end"}, "fill": {"field": "category","scale": "color"} } } }, { "type": "text", "properties": { "enter": { "radius": { "scale": "radius", "field": "year", "offset": 30 }, "theta": {"value":1.2}, "x": 100, "y": 100, "text": {"field": "year"}, "fill": {"value": "#eec"}, "fontSize": {"value": 18} } } } ] } ] }</graph>

Yurik thanks for challenging me :) Ad Huikeshoven (talk) 17:57, 28 December 2015 (UTC)[reply]

Ad Huikeshoven, awesome!!! I played with it a bit, seems really good! I found graph to be easier to read if the gap is only one pixel - looks a bit more readable imho, but that probably depends on the specifics of the data. I wonder if radius offsets should be somehow tied to the scales instead of being hardcoded. Also, usually I prefer shorter labels for the data, one char best. But I'm neat-picking, it looks awesome :)) --Yurik (talk) 18:46, 28 December 2015 (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]

Legend font too small and backward compatibility with Template:Pie chart

[edit]

Is it just me who find the legend key in this too small (and ugly!)? Also, shouldn't this template be made backward compatible with {{pie chart}} for easy conversion? Cheers. Guarapiranga (talk) 01:39, 9 November 2019 (UTC)[reply]