Get data point positions?

I am attempting to do some custom drawing to “label” the data points. In order to do this I need the x and y of each data point. How do I access this information?

var draw = Chart.controllers.line.prototype.draw;
Chart.controllers.line = Chart.controllers.line.extend({
    draw: function() {, arguments[0]);

        var ctx = this.chart.chart.ctx;
        var points = // how do I get the data points positions?
        $.each (points, function (k, v)
            ctx.moveTo(v.x, v.y);
            ctx.lineWidth = 3;
            ctx.strokeStyle = '#ff0000';
            ctx.lineTo(0, v.y);

Author: Fantashit

2 thoughts on “Get data point positions?

  1. You can use the following code. chart is the chart you have created (replace with this if calling from inside chart). Replace n with the dataset that you want and replace i with the point that you want. Both are zero-based indexes.

    var meta = chart.getDatasetMeta(n);
    var x =[i]._model.x;
    var y =[i]._model.y;

Comments are closed.