[Chartjs]-Charts.js rendering issue on page load

1👍

The data used by the chart is not available when the chart is created. This is because the ajax call is asynch, and the data becomes available only when the ajax request is complete.
In order to have the chart visible right away, you will need to use this call myChart.update(), in the “done” function of the ajax call after you populate the data, in order to update the chart:

...
data.forEach(function(item) {
    dates.push(item.date);
    clientCosts.push(item.clientCostsTotal);
});
myChart.update();

Leave a comment