ChartJS Line Chart
Multiple Line Chart
HTML
<body>
<canvas id="chartJSContainer" width="600" height="400"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.0.0-rc.6/chart.js" crossorigin="anonymous"></script>
</body>
CSS
canvas { background-color : #eee;
}
JavaScript
Chart.register({
id: 'version',
afterDraw(chart) {
const ctx = chart.ctx;
ctx.save();
ctx.font = '9px monospace';
ctx.fillStyle = 'rgba(0, 0, 0, 0.5)';
ctx.textAlign = 'right';
ctx.textBaseline = 'top';
ctx.fillText('Chart.js v' + Chart.version, chart.chartArea.right, 0);
ctx.restore();
}
});
var options = {
type: 'bar',
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
}
]
},
}
var ctx = document.getElementById('chartJSContainer').getContext('2d');
new Chart(ctx, options);