Chartjs-Getting 'Uncaught TypeError: Cannot read property 'helpers' of undefined'

1πŸ‘

It seems that in both cases you are resolving the single Promises when the first element in dependentScripts and listOfScriptsare loaded and not when all of them are loaded. I.e., you are not waiting for all the dependentScripts and listOfScripts before resolving the Promise.

0πŸ‘

I think I’ve found a solution for loading dependent scripts in my case.
So the plugin DataLabels is only loaded when chartjs is resolved.

$.when(
    $.getScript(`libs/chartjs.min.js`),
    $.Deferred(function(deferred) {
        $(deferred.resolve);
    })
).done(function() {
    $.getScript(`libs/chartjs-plugin-datalabels.js`)
    //Load other scripts
    Promise.all([loadScripts(), loadCss()])
        .then(() => {

            //do stuff ...

        });
});

0πŸ‘

we have two file 1. chart.js and 2. datalabels.plugins these two files enough for create different types of charts and datalabels plugins responsible for labels of data so that first attach your file "chartjs" and after datalabels plugins. So first load chartjs and then any plugins.

Leave a comment