score:10

Accepted answer

plugins should be placed in its own config section, and not nested under options.

instead of:

options: {
    title: {
        display: true,
        text: graph.globals.title,
    },
    legend: {
        display: true,
        position: 'bottom',
        fullwidth: false,
        onclick: () => {},
        labels: {
            generatelabels: (chart) => {
                return pieoptions.legendleft(chart);
            }
        }
    },
    plugins: [{
        beforeinit: function(chart, options) {
            console.log('yolo');
        }
    }]
    rotation: 3.9,
}

your code should look like:

options: {
    title: {
        display: true,
        text: graph.globals.title,
    },
    legend: {
        display: true,
        position: 'bottom',
        fullwidth: false,
        onclick: () => {},
        labels: {
        //   generatelabels: (chart) => {
        //      return pieoptions.legendleft(chart);
        //    }
        }
    },
    rotation: 3.9,
},
plugins: [{
    beforeinit: function(chart, options) {
        console.log('yolo');
    }
}]

working jsfiddle: https://jsfiddle.net/r1x63b8v/


Related Query

More Query from same tag