score:1

i faced this issue as well, i managed to fix it like this: this is an example for the chartjs-plugin-annotation

what i forgot was to register the plugin in the beforedraw event

const chartjsnode = require('chartjs-node');
const chartjsannotation = require('chartjs-plugin-annotation');

var chartnode = new chartjsnode(width, height);
chartnode.on('beforedraw', function (chartjs) {

    // register the annotation plugin
    chartjs.plugins.register( chartjsannotation );
});

chartnode.drawchart( <your_chartjs_configuration> )
.then( function(){
    // save as testimage.png
    chartnode.writeimagetofile('image/png', './testimage.png'); 
});

and your configuration (example):

type: 'line',
data: {
   ...
},
options: {
    ...
    annotation: {
        annotations: [{
            value: 100,
            type: 'line',
            mode: 'horizontal',
            scaleid: 'y-axis-0',
            bordercolor: '#d2dae2',
            borderwidth: 1,
            borderdash: [2, 2],
            label: {
                content: 'value 1'
            }
        }, {
            value: 50
            type: 'line',
            mode: 'horizontal',
            scaleid: 'y-axis-0',
            bordercolor: '#d2dae2',
            borderwidth: 1,
            borderdash: [2, 2],
            value: 500,
            label: {
                content: 'value 2'
             }
        }]
    }

Related Query

More Query from same tag