Widget:StatsGraph: Difference between revisions
Jump to navigation
Jump to search
Default value for graphId and added proper Documentation tag |
m GraphId generation testing |
||
Line 99: | Line 99: | ||
function genIdIfNeeded(graphId) { | function genIdIfNeeded(graphId) { | ||
console.log("GraphId: ", graphId); | |||
if (graphId && graphId.length > 0) { | if (graphId && graphId.length > 0) { | ||
return graphId; | return graphId; | ||
} | } | ||
return ' | return 'Fxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { | ||
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); | var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); | ||
return v.toString(16); | return v.toString(16); | ||
Line 109: | Line 110: | ||
var graphData = JSON.parse(`<!--{$data|escape:'html'}-->`.replace(/"/gi, '"')); | var graphData = JSON.parse(`<!--{$data|escape:'html'}-->`.replace(/"/gi, '"')); | ||
buildGraph(genIdIfNeeded("<!--{$graphId|escape:'html'}-->"), graphData);</script></includeonly><noinclude>{{Documentation}}</noinclude> | buildGraph(genIdIfNeeded("<!--{$graphId|escape:'html'}-->"), graphData);</script></includeonly><noinclude>{{Documentation}}{{#widget:StatsGraph | ||
|data=[ | |||
{ | |||
"class": "graph-orange", | |||
"data": [ | |||
{ | |||
"label": "RoF", | |||
"min": 12, | |||
"max": 37, | |||
"value": 32 | |||
}, | |||
{ | |||
"label": "Acc", | |||
"min": 12, | |||
"max": 37, | |||
"value": 32 | |||
}, | |||
{ | |||
"label": "Dmg", | |||
"min": 12, | |||
"max": 37, | |||
"value": 32 | |||
} | |||
] | |||
}, | |||
{ | |||
"class": "graph-blue", | |||
"data": [ | |||
{ | |||
"label": "RoF", | |||
"min": 12, | |||
"max": 37, | |||
"value": 18 | |||
}, | |||
{ | |||
"label": "Acc", | |||
"min": 12, | |||
"max": 37, | |||
"value": 26 | |||
}, | |||
{ | |||
"label": "Dmg", | |||
"min": 12, | |||
"max": 37, | |||
"value": 22 | |||
} | |||
] | |||
} | |||
]}}</noinclude> |
Revision as of 22:30, 2 October 2019
Widget to create an SVG image containing a radar chart. It is configured with a JSON string.
Parameters
Parameter name | Required? | Default value | Description |
---|---|---|---|
data |
Yes | (n/a) | A JSON String containing all values. Please make sure that
See the testcases for examples how to configure the JSON string. |
Usage
See the template's testcases:
Small graph using default colors | |
---|---|
Wiki code | {{#widget:StatsGraph |data=[ { "data": [ { "label": "RoF", "min": 12, "max": 37, "value": 14 }, { "label": "Acc", "min": 34, "max": 68, "value": 37 }, { "label": "Dmg", "min": 9, "max": 12, "value": 11 } ] } ]}} |
Main version | |
Sandbox version | Error in widget StatsGraph/sandbox: Unable to load template 'wiki:StatsGraph/sandbox'
|
Graph showing two graphs, second graph with different color | |
---|---|
Wiki code | {{#widget:StatsGraph |data=[ { "data": [ { "label": "RoF", "min": 12, "max": 37, "value": 32 }, { "label": "Acc", "min": 12, "max": 37, "value": 32 }, { "label": "Dmg", "min": 12, "max": 37, "value": 32 } ] }, { "fill": "blue", "stroke": "darkblue", "data": [ { "label": "RoF", "min": 12, "max": 37, "value": 34 }, { "label": "Acc", "min": 34, "max": 68, "value": 51 }, { "label": "Dmg", "min": 9, "max": 12, "value": 9 } ] } ]}} |
Main version | |
Sandbox version | Error in widget StatsGraph/sandbox: Unable to load template 'wiki:StatsGraph/sandbox'
|
Graph with more properties | |
---|---|
Wiki code | {{#widget:StatsGraph |data=[ { "data": [ { "label": "RoF", "min": 12, "max": 37, "value": 14 }, { "label": "Acc", "min": 34, "max": 68, "value": 37 }, { "label": "Dmg", "min": 9, "max": 16, "value": 11 }, { "label": "Dmg1", "min": 9, "max": 16, "value": 12 }, { "label": "Dmg2", "min": 9, "max": 16, "value": 13 }, { "label": "Dmg3", "min": 9, "max": 16, "value": 14 } ] } ]}} |
Main version | |
Sandbox version | Error in widget StatsGraph/sandbox: Unable to load template 'wiki:StatsGraph/sandbox'
|
The above documentation is transcluded from Widget:StatsGraph/doc. (edit | history) |