ChartJS Line Chart
Multiple Line Chart
by thomasa88
HTML
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
</body>
CSS
canvas { background-color : #eee;
}
JavaScript
var options = {
type: 'line',
data: {
labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
datasets: [{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
borderWidth: 1
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
borderWidth: 1
}
]
},
options: {
scales: {
x: {
grid: {
display: true,
color: (line) => (line.index === 0 ? 'red' : 'rgba(0, 0, 0, 0)')
},
},
y: {
grid: {
color: (line) => (line.index === 5 ? 'red' : 'rgba(0, 0, 0, 0.1)')
}
}
}
}
}
var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);