Editing User:Fbstj/edits-pie

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 2: Line 2:
 
https://coppermind.net/w/api.php?action=query&format=json&list=allusers&augroup=editor&auprop=editcount&auwitheditsonly=1
 
https://coppermind.net/w/api.php?action=query&format=json&list=allusers&augroup=editor&auprop=editcount&auwitheditsonly=1
   
''NB:'' the percentages are a little iffy as [[Special: Statistics]] shows an edit-total which makes my % more like 25%.
+
''NB:'' the percentages are a little iffy
   
 
{{#tag:graph|
 
{{#tag:graph|
Line 111: Line 111:
 
"name": "table",
 
"name": "table",
 
"url": "wikiapi://coppermind.net/?action=query&format=json&list=allusers&auprop=editcount&aulimit=max&augroup=keeper&auwitheditsonly=1",
 
"url": "wikiapi://coppermind.net/?action=query&format=json&list=allusers&auprop=editcount&aulimit=max&augroup=keeper&auwitheditsonly=1",
// We are only interested in the content of query.allusers subelement.
 
"format": {"property": "query.allusers","type": "json"},
 
"transform": [
 
// sort in descending order using category size as the sort key
 
{"type": "sort","by": "-editcount"},
 
// 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": "editcount"}
 
]
 
}
 
],
 
// "legends": [{"title": "{{{legend|Legend}}}","fill": "color"}],
 
// 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": "name"},
 
"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": "name"},
 
"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
 
"type": "text",
 
// 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": "name", "expr": "substring(datum.name, 1+indexof(datum.name,':'), 40) +': '+ datum.editcount + ' ('+ round(datum.sliceSize * 100 / 180) +'%)'" },
 
// 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'" }
 
]
 
},
 
"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": "name"},
 
"theta": {"field": "layout_mid"}
 
}
 
}
 
}
 
]
 
}
 
}}
 
 
== Active Users ==
 
This is flawed as it shows total edits for all [[Special: ActiveUsers|"active users"]] and so is overwhelmed by recent big editors
 
{{#tag:graph|
 
{
 
"version": 2,
 
"width": 300,
 
"height": 300,
 
"data": [
 
{
 
// Data is retrieved from the MediaWiki API. By default it uses current wiki's "Extension by category"
 
"name": "table",
 
"url": "wikiapi://coppermind.net/?action=query&format=json&list=allusers&auprop=editcount&aulimit=max&auactiveusers=1",
 
 
// We are only interested in the content of query.allusers subelement.
 
// We are only interested in the content of query.allusers subelement.
 
"format": {"property": "query.allusers","type": "json"},
 
"format": {"property": "query.allusers","type": "json"},

Please note that all contributions to The Coppermind are considered to be released under the CC4 by-nc-nd (see Coppermind:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)