ChartJS Line Chart
Multiple Line Chart
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.3.0/Chart.js"></script>
<body>
<canvas id="chartJSContainer" width="100" height="100"></canvas>
<img src="" id="coolImage" class="img-fluid" alt="Responsive image">
<button id="create">Create image</button>
</body>
CSS
#chartJSContainer {
opacity:0.2;
}
#coolimage {
border:1px solid blue;
}
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,
backgroundColor: 'rgba(255, 0, 15, 0.54)'
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
borderWidth: 1
}
]
},
options: {
label: {
fontSize: 50
},
scales: {
yAxes: [{
ticks: {
reverse: false
}
}]
}
}
}
var canvas = document.getElementById('chartJSContainer');
var ctx = canvas.getContext('2d');
var lineChart = new Chart(ctx, options);
var button = document.getElementById("create")
button.addEventListener("click", function() {
var dataURL = canvas.toDataURL();
console.log(dataURL);
document.getElementById('coolImage').src = dataURL;
})