User:Wyang/graphs

{ "version": 2, "width": 300, "height": 300, "data": [ {     // Data is retrieved from the MediaWiki API. "name": "table", "url": "wikiapi:///?action=query&prop=categoryinfo&titles=Category:English lemmas|Category:Italian lemmas|Category:Mandarin lemmas|Category:Finnish lemmas|Category:Chinese lemmas|Category:French lemmas|Category:Serbo-Croatian lemmas|Category:Portuguese lemmas|Category:Cantonese lemmas|Category:Japanese lemmas|Category:Spanish lemmas|Category:German lemmas|Category:Russian lemmas|Category:Latin lemmas|Category:Czech lemmas|Category:Dutch lemmas|Category:Korean lemmas|Category:Min Nan lemmas|Category:Hungarian lemmas|Category:Swedish lemmas|Category:Greek lemmas|Category:Polish lemmas|Category:Esperanto lemmas|Category:Georgian lemmas|Category:Irish lemmas|Category:Macedonian lemmas|Category:Catalan lemmas|Category:Vietnamese lemmas|Category:Hakka lemmas|Category:Armenian lemmas|Category:Telugu lemmas|Category:Icelandic lemmas|Category:Norwegian Bokmål lemmas|Category:Romanian lemmas|Category:Latvian lemmas|Category:Turkish lemmas|Category:Scottish Gaelic lemmas|Category:Norman lemmas|Category:Translingual lemmas|Category:Arabic lemmas|Category:Danish lemmas|Category:Persian lemmas|Category:Norwegian Nynorsk lemmas|Category:Old French lemmas|Category:Hebrew lemmas|Category:Ancient Greek lemmas|Category:Manx lemmas|Category:Old Armenian lemmas|Category:Hindi lemmas|Category:Albanian lemmas|Category:Ido lemmas|Category:Galician lemmas|Category:Luxembourgish lemmas|Category:Asturian lemmas|Category:Thai lemmas|Category:Old English lemmas|Category:Faroese lemmas|Category:Estonian lemmas|Category:Middle Chinese lemmas|Category:Old Chinese lemmas|Category:Adyghe lemmas|Category:Navajo lemmas|Category:Bulgarian lemmas|Category:Malay lemmas|Category:Proto-Germanic lemmas|Category:Malagasy lemmas|Category:Slovene lemmas|Category:Middle French lemmas|Category:Yiddish lemmas|Category:Slovak lemmas|Category:Swahili lemmas|Category:Norwegian lemmas|Category:Lithuanian lemmas|Category:Welsh lemmas|Category:Ukrainian lemmas|Category:Aromanian lemmas|Category:Volapük lemmas|Category:Classical Nahuatl lemmas|Category:Old Church Slavonic lemmas|Category:Venetian lemmas|Category:Sanskrit lemmas|Category:Classical Syriac lemmas|Category:Northern Sami lemmas|Category:Crimean Tatar lemmas|Category:Indonesian lemmas|Category:Urdu lemmas|Category:Lojban lemmas|Category:Afrikaans lemmas|Category:Bengali lemmas|Category:Old Saxon lemmas|Category:Belarusian lemmas|Category:Romansch lemmas|Category:Aramaic lemmas|Category:Kurdish lemmas|Category:Tagalog lemmas|Category:Middle English lemmas|Category:Khmer lemmas|Category:Wu lemmas|Category:Old Irish lemmas|Category:Basque lemmas|Category:Quechua lemmas|Category:Bashkir lemmas|Category:Friulian lemmas|Category:Occitan lemmas|Category:Maltese lemmas|Category:Old Norse lemmas|Category:Ladin lemmas|Category:Lower Sorbian lemmas|Category:Interlingua lemmas|Category:Ladino lemmas|Category:Hawaiian lemmas|Category:Mongolian lemmas|Category:Azeri lemmas|Category:Veps lemmas|Category:Vilamovian lemmas|Category:Cebuano lemmas|Category:Proto-Slavic lemmas|Category:Hiligaynon lemmas|Category:Breton lemmas|Category:Lao lemmas|Category:West Frisian lemmas|Category:Old High German lemmas|Category:Pashto lemmas|Category:Pali lemmas|Category:Dalmatian lemmas|Category:Sicilian lemmas|Category:Tajik lemmas|Category:Saterland Frisian lemmas|Category:Haitian Creole lemmas|Category:Mapudungun lemmas|Category:Greenlandic lemmas|Category:Tok Pisin lemmas|Category:Chuukese lemmas|Category:Tamil lemmas|Category:Burmese lemmas|Category:Kabardian lemmas|Category:Neapolitan lemmas|Category:Gothic lemmas|Category:Nepali lemmas|Category:Scots lemmas|Category:Proto-Samic lemmas|Category:Min Dong lemmas|Category:Egyptian lemmas|Category:Ottoman Turkish lemmas|Category:Somali lemmas|Category:Novial lemmas|Category:Low German lemmas|Category:Proto-Indo-European lemmas|Category:Old Portuguese lemmas|Category:Proto-Finnic lemmas&formatversion=2&format=json", // We are only interested in the content of query.pages subelement. "format": {"property": "query.pages","type": "json"}, "transform": [ // sort in descending order using category size as the sort key {"type": "sort","by": "-categoryinfo.size"}, // To visualize, use "pie" transformation to add layout_start, layout_end, and layout_mid fields to each page object // These fields contain angles at which to start and stop drawing arcs. First element's start will be 0, and last element's end will be 360 degrees (in radians) {"type": "pie","field": "categoryinfo.size"} ]   }  ],  // Scales are like functions -- marks use them to convert a data value into a visual value, like x or y coordinate on the graph, or a color value. "scales": [ {     // This scale will be used to assign a color to each slice, using a palette of 10 colors "name": "color", "domain": {"data": "table","field": "title"}, "range": "category20", "type": "ordinal" } ],  "marks": [ {     // This mark draws the actual pie chart from the data source // Each element is an arc between layout_start and layout_end angles (as calculated by the pie transformation) // drawn with a given radius, stroke, and fill. "from": {"data": "table"}, "type": "arc", "properties": { "enter": { "fill": {"scale": "color","field": "title"}, "outerRadius": {"value": 200}, "startAngle": {"field": "layout_start"}, "endAngle": {"field": "layout_end"}, "stroke": {"value": "white"}, "strokeWidth": {"value": 1} }     }    },    {      // This mark draws labels around the pie chart after the pie chart has been drawn // Before drawing, we need to perform a number of calculations to figure out the exact location and orientation of the text "from": { "data": "table", "transform": [ // For each data point (datum), each of these transformations will be ran in order. // Formula transformation evaluates the expression and assigns result to the datapoint // Size of the pie slice, in degrees: sliceSize = (end - start) * 180 / Pi          { "type": "formula", "field": "sliceSize", "expr": "(datum.layout_end - datum.layout_start)*180/PI" }, // Draw text only if the slice of the arc is more than 2 degrees to avoid overcrowding { "type": "filter", "test": "datum.sliceSize > 2" }, // Remove namespace from the text - keeps only text after the first ':' symbol, limits to 40 chars. { "type": "formula", "field": "title", "expr": "substring(datum.title, 1+indexof(datum.title,':'), 40)" }, // Determine the side of the pie chart we are on - left or right. { "type": "formula", "field": "invert", "expr": "datum.layout_mid*180/PI < 180 ? 1 : -1" }, // If on the left, the text should be right-aligned (go from the rim inward) { "type": "formula", "field": "align", "expr": "datum.invert < 0 ? 'left' : 'right'" }, // At what angle should the text be drawn relative to the point on the circle { "type": "formula", "field": "angle", "expr": "(datum.layout_mid*180/PI)-90*datum.invert" }, // Make font smaller for smaller pie slices { "type": "formula", "field": "fontSize", "expr": "datum.sliceSize > 20 ? 15 : (datum.sliceSize > 10 ? 14 : 10)" }, // Make font bold for largest pie slices { "type": "formula", "field": "fontWeight", "expr": "datum.sliceSize > 15 ? 'bold' : 'normal'" } ]     },      "type": "text", "properties": { "enter": { // Use the fields calculated in the transformation to draw category names "align": {"field": "align"}, "angle": {"field": "angle"}, "baseline": {"value": "middle"}, "fill": {"value": "black"}, "fontSize": {"field": "fontSize"}, "fontWeight": {"field": "fontWeight"}, "radius": {"value": 270}, "text": {"field": "title"}, "theta": {"field": "layout_mid"} }     }    }  ] }

Plot of  over the last few years (using sequential data from Statistics):