From Dark and Darker Wiki
No edit summary |
No edit summary |
||
(18 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
<includeonly> | <includeonly> | ||
<div> | <div> | ||
<canvas id="<!--{$ | <canvas id="<!--{$uniqueId|escape:'html'}-->"></canvas> | ||
</div> | </div> | ||
<script> | <script> | ||
var data = JSON.parse('<!--{$data|escape:'quotes'}-->'); | |||
var color = '<!--{$color|escape:'quotes'}-->'; | |||
var gridColor = '<!--{$gridColor|escape:'quotes'}-->'; | |||
var axisColor = '<!--{$axisColor|escape:'quotes'}-->'; | |||
var fontColor = '<!--{$fontColor|escape:'quotes'}-->'; | |||
if (color == "") { | |||
color = "black"; | |||
} | |||
if (gridColor == "") { | |||
if ( | gridColor = "lightgray"; | ||
} | |||
if (axisColor == "") { | |||
axisColor = gridColor; | |||
} | } | ||
if ( | |||
if (fontColor == "") { | |||
fontColor = "gray"; | |||
} | } | ||
var max = | var max = data[0]["x"]; | ||
var min = max; | var min = max; | ||
for (let i = 0; i < | for (let i = 0; i < data.length; i++) { | ||
if ( | if (data[i]["x"] > max) { | ||
max = | max = data[i]["x"]; | ||
} | } | ||
if ( | if (data[i]["x"] < min) { | ||
min = | min = data[i]["x"]; | ||
} | } | ||
} | } | ||
Line 33: | Line 40: | ||
var range = [...Array(max - min + 1).keys()].map((x) => x + min); | var range = [...Array(max - min + 1).keys()].map((x) => x + min); | ||
new Chart(document.getElementById('<!--{$ | new Chart(document.getElementById('<!--{$uniqueId|escape:'html'}-->'), { | ||
type: "line", | type: "line", | ||
axisX: { | axisX: { | ||
Line 43: | Line 50: | ||
{ | { | ||
data: data, | data: data, | ||
borderColor: color, | |||
borderColor: | backgroundColor: color, | ||
backgroundColor: | |||
fill: false, | fill: false, | ||
}, | }, | ||
], | ], | ||
}, | }, | ||
options: { | |||
plugins:{ | |||
legend: { | |||
display: false | |||
} | |||
}, | |||
scales: { | |||
y: { | |||
grid: { | |||
color: gridColor | |||
}, | |||
border: { | |||
color: axisColor | |||
}, | |||
ticks: { | |||
color: fontColor | |||
} | |||
}, | |||
x: { | |||
type: 'linear', | |||
grid: { | |||
color: gridColor | |||
}, | |||
border: { | |||
color: axisColor | |||
}, | |||
ticks: { | |||
color: fontColor | |||
} | |||
} | |||
} | |||
} | |||
}); | }); | ||
</script> | </script> | ||
</includeonly> | </includeonly> |