Chartjs-2 or more charts on same page?

0👍

Your two JavaScript blocks are almost same( same config, same functions, etc…), I refactor to clarify.

Look for my working example: Chart.js multiple charts in same page

Initialize the charts:

...
function onLoadOverride(chartId, config) {
    var ctx1 = document.getElementById(chartId).getContext("2d");
    new Chart(ctx1, config);
}
onLoadOverride("myChart1", config);
onLoadOverride("myChart2", config);
...

Leave a comment