Chart.js/samples/scales/gridlines-scriptable.html
LeeLenaleee c3fbe5efc3
Fix/area fill and chart titles (#8113)
* fixed fill for area chart stacked and title for charts where it wasn't in plugins yet
* Chart defined in utils
* added radar skip points example in the overview to go to
2020-11-30 09:59:20 -05:00

75 lines
1.5 KiB
HTML

<!doctype html>
<html>
<head>
<title>Grid Lines Scriptable Settings</title>
<script src="../../dist/chart.min.js"></script>
<script src="../utils.js"></script>
<style>
canvas{
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
</style>
</head>
<body>
<div style="width:75%;">
<canvas id="canvas"></canvas>
</div>
<script>
var config = {
type: 'line',
data: {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'My First dataset',
backgroundColor: window.chartColors.red,
borderColor: window.chartColors.red,
data: [10, 30, 39, 20, 25, 34, -10],
fill: false,
}, {
label: 'My Second dataset',
fill: false,
backgroundColor: window.chartColors.blue,
borderColor: window.chartColors.blue,
data: [18, 33, 22, 19, 11, -39, 30],
}]
},
options: {
responsive: true,
plugins: {
title: {
display: true,
text: 'Grid Line Settings'
}
},
scales: {
y: {
gridLines: {
drawBorder: false,
color: function(context) {
if (context.tick.value > 0) {
return window.chartColors.green;
} else if (context.tick.value < 0) {
return window.chartColors.red;
}
return '#000000';
},
},
}
}
}
};
window.onload = function() {
var ctx = document.getElementById('canvas').getContext('2d');
window.myLine = new Chart(ctx, config);
};
</script>
</body>
</html>