[Chartjs]-Changing the background of a ChartJS on node js

3👍

Just extend Chart.js to do this, like so

Chart.types.Line.extend({
    name: "LineAlt",
    draw: function () {
        Chart.types.Line.prototype.draw.apply(this, arguments);

        var ctx = this.chart.ctx;
        ctx.globalCompositeOperation = 'destination-over';
        ctx.fillStyle = 'rgba(0,0,255,0.2)';
        ctx.fillRect(0, 0, this.chart.width, this.chart.height);
        ctx.globalCompositeOperation = 'source-over';
    }
});

and then

...
new Chart(ctx).LineAlt(data);

Fiddle – http://jsfiddle.net/q7v5qzzg/

0👍

scaleGridLineColor : “rgba(0,0,0,0)”

pass this as one of the configuration values

Leave a comment