[Chartjs]-How to draw line graph with line animation from left to right using chartjs?

3👍

You can extend the chart and override the starting values for the animation in the initialize override, like so

Chart.types.Line.extend({
    name: "LineAlt",
    initialize: function(data){
        Chart.types.Line.prototype.initialize.apply(this, arguments);
        this.eachPoints(function(point, index){
            Chart.helpers.extend(point, {
                x: this.scale.calculateX(0),
                y: this.scale.calculateY(point.value)
            });
            point.save();
        }, this);       
    }
});

Then just use the extended chart, like so

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

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

Leave a comment