From Dark and Darker Wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<includeonly> | <includeonly> | ||
<div> | <div> | ||
<canvas id=" | <canvas id="<!--{$id|escape:'html'}-->"></canvas> | ||
</div> | </div> | ||
Line 7: | Line 7: | ||
<script> | <script> | ||
var data = JSON.parse('<!--{$data|escape:'quotes'}-->') | |||
new Chart( | var label = '<!--{$label|escape:'quotes'}-->'; | ||
type: | var borderColor = '<!--{$borderColor|escape:'quotes'}-->'; | ||
var backgroundColor = '<!--{$backgroundColor|escape:'quotes'}-->'; | |||
if (colorData == "") { | |||
colorData = "black"; | |||
} | |||
if (backgroundColorData == "") { | |||
backgroundColorData = "transparent"; | |||
} | |||
var max = statsData[0]["x"]; | |||
var min = max; | |||
for (let i = 0; i < statsData.length; i++) { | |||
if (statsData[i]["x"] > max) { | |||
max = statsData[i]["x"]; | |||
} | |||
if (statsData[i]["x"] < min) { | |||
min = statsData[i]["x"]; | |||
} | |||
} | |||
var range = [...Array(max - min + 1).keys()].map((x) => x + min); | |||
new Chart(document.getElementById('<!--{$id|escape:'html'}-->'), { | |||
type: "line", | |||
axisX: { | |||
gridColor: "orange", | |||
}, | |||
data: { | data: { | ||
labels: | labels: range, | ||
datasets: [{ | datasets: [ | ||
{ | |||
data: data, | |||
label: label, | |||
borderColor: borderColor, | |||
backgroundColor: backgroundColor, | |||
fill: false, | |||
}, | |||
], | |||
}, | }, | ||
}); | }); | ||
</script> | </script> | ||
</includeonly> | </includeonly> |