score:2

you can extend chart.js to do this. just override the showtooltip method after initializing the chart.


preview

enter image description here


script

chart.types.line.extend({
    name: "linealt",
    initialize: function () {
        chart.types.line.prototype.initialize.apply(this, arguments);

        var originalshowtooltip = this.showtooltip;
        this.showtooltip = function (activepoints) {

            if (activepoints.length) {
                var ctx = this.chart.ctx;
                var scale = this.scale;
                ctx.save();
                ctx.strokestyle = '#aaa';
                ctx.beginpath();
                ctx.moveto(activepoints[0].x, scale.startpoint);
                ctx.lineto(activepoints[0].x, scale.endpoint);
                ctx.stroke();
                ctx.restore();
            }

            return originalshowtooltip.apply(this, arguments);
        }
    }
});

and then

new chart(ctx).linealt(data);

fiddle - http://jsfiddle.net/98gz1fhw/


Related Query

More Query from same tag