chartjs / chartjs-plugin-deferred

Chart.js plugin to defer initial chart updates
https://chartjs-plugin-deferred.netlify.app/
MIT License
108 stars 21 forks source link

Error with global plugins #11

Closed luccaclemente closed 6 years ago

luccaclemente commented 6 years ago

I'm getting the message "e.defaults.global.plugins is undefined" when trying to use the plugin on my charts.

Any help?

simonbrunel commented 6 years ago

e.defaults.global.plugins doesn't exist, it should be Chart.defaults.global.plugins

luccaclemente commented 6 years ago

My chart code:

`var ctx = document.getElementById('chart-1-container').getContext('2d'); var chart = new Chart(ctx, { // The type of chart we want to create type: 'line',

            // The data for our dataset
            data: {
                labels: labels1,
                datasets: [{
                    label: "Total de acessos",                  
                    borderColor: 'rgb(255, 99, 132)',                   
                    data: data1,
                }]
            },              
            // Configuration options go here
            options: {
                plugins: {
                datalabels: {
                    backgroundColor: function(context) {
                        return context.dataset.backgroundColor;
                    },
                    borderRadius: 4,
                    color: 'white',
                    font: {
                        weight: 'bold'
                    },
                }
            },
            scales: {
                yAxes: [{
                    stacked: true
                }]
            }

            }
        });`

The files I imported:

`

` The chart is displaying correctly, but there is no label of the data on it.
simonbrunel commented 6 years ago

... but there is no label of the data on it.

This is the deferred plugin, try the datalabels plugin instead!