mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-08 05:09:08 +02:00
986f72f933
* Rename dist/Chart* to dist/chart* * Add a note to migration docs * Review update
73 lines
1.5 KiB
HTML
73 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,
|
|
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>
|