score:0

after some search i found a solution changing the event of plugin to beforedraw and calling the update() method of chart.

this.chartinst = new chart(this._ctx, {
        type: "line",
        data: this._data ,
        options: this._chartoptions,
        plugins: [{
            beforedraw: function (c, a, o) {
                var yscale = c.scales['y'];                   
                var max = c.data.datasets[0].data.reduce(function (prev, current) { return (prev.y > current.y) ? prev : current }).y;
                var ypos = yscale.getpixelforvalue(max);
                var gradientfill = c.ctx.createlineargradient(0, ypos, 0, c.height);
                gradientfill.addcolorstop(0.4, 'rgba(83, 155, 243, 0.25)');
                gradientfill.addcolorstop(0.9, 'rgba(223,140,255,0.25)');
                c.data.datasets[0].backgroundcolor = gradientfill;
                c.update();
            }
        }]
    })

Related Query

More Query from same tag