Sjabloon:Grafiek Ledentallen Politieke Partijen
Uit Wiki Raamsdonk
<graph> {
// // ATTENTION: This code is maintained at https://www.mediawiki.org/wiki/Template:Graph:Lines // Please do not modify it anywhere else, as it may get copied and override your changes. // Suggestions can be made at https://www.mediawiki.org/wiki/Template_talk:Graph:Lines // // Template translation is in https://commons.wikimedia.org/wiki/Data:Original/Template:Graphs.tab //
"version": 2, "width": 500, "height": 300,
"padding": "strict",
"signals": [{"name": "rightwidth", "expr": "width + padding.right", "init":"500"}],
"data": [{
"name": "chart",
"url": "wikidatasparql:///?query=SELECT%20%3Fdate%20%3Fmembers%20%7B%0A%20%20%20%20wd%3A%20p%3AP2124%20%3Fp%20.%0A%20%20%20%20%3Fp%20pq%3AP585%20%3Fdate%20%3B%0A%20%20%20%20%20%20%20ps%3AP2124%20%3Fmembers%20.%0A%20%20%7D%0A%20%20ORDER%20BY%20%3Fdate",
"format": {"type": "json"
, "parse": {"date": "date"}
},
"transform": [
// Convert xField parameter into a field "_xfield"
{"type": "formula", "field": "_xfield", "expr":
"datum.date"
}
, {"type": "sort", "by": ["_xfield"]}
, {"type": "fold", "fields": ["members"]} , {"type": "formula", "field": "_yfield", "expr": "datum.value" }
] },
],
"scales": [
{
"name": "x",
"type": "time",
"domain": {"data": "chart", "field": "_xfield"},
"range": "width",
},
{
"name": "y",
"type": "linear",
"range": "height",
"domain": {"data": "chart", "field": "_yfield"},
"zero": false,
},
{
"name": "color",
"type": "ordinal",
"range": "category10",
"domain": {"data": "chart", "field": "key"}
},
{
"name": "labels",
"type": "ordinal",
"domain": ["members"],
"range": ["members"], } ],
"axes": [
{
"scale": "x", "type": "x", "tickSizeEnd": 0,
"ticks": 7,
"grid": true,
"properties": {
"labels": {
}
}
},
{
"scale": "y", "type": "y", "tickSizeEnd": 0,
"grid": true,
"properties": {
"labels": {
}
}
}
],
"marks": [
// Group data by the group parameter or "key", and draw lines, one line per group
{
"type": "group",
"from": {
"data": "chart",
"transform": [{"type": "facet", "groupby": ["key"]}]
},
"marks": [
{
"type": "line",
"properties": {
"hover": {
"stroke": {"value": "red"}
},
"update": {
"stroke": {"scale": "color", "field": "key"}
},
"enter": {
"y": {"scale": "y", "field": "_yfield"},
"x": {"scale": "x", "field": "_xfield"},
"stroke": {"scale": "color", "field": "key"},
"interpolate": {"value": "linear"},
"strokeWidth": {"value": 2.5}
}
}
}
],
},
// Draw title at the top of the graph
{
"type": "text",
"properties": {
"enter": {
"y": {"value": -15},
"x": {"signal": "rightwidth", "mult": 0.5, "offset": 0 },
"text": {"value": "Ledentallen"},
"fontWeight": {"value": "bold"},
"align": {"value": "center"},
"baseline": {"value": "bottom"},
"fill": {"value": "#000"}
}
}
}
]
} </graph>
Lua-fout: bad argument #1 to "get" (not a valid title)..
