Chart.js working fine on my localhost but it is not working online

๐Ÿ‘:0

I think the problem is, chart function is being called before it get the data.

window.onload = function () {
    setTimeout(function () {
        var ctx = document.getElementById("valueChart").getContext("2d");
        window.myLine = new Chart(ctx).Line(lineChartData, {
            responsive: true
        });
    }, 1000);

}

Suppose it is just an example of your solution to understand. Here lineChartData is the data object to show in the chart. And to handle this data within the chart I have used a settimeout function with 1 second delay. You can check with this code if your problem is late loading or not, if yes then you can create any other event handler to load your objects and functions serially.

Leave a comment