question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get data point positions?

See original GitHub issue

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() {
        draw.call(this, arguments[0]);

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

35reactions
panzarinocommented, May 4, 2016

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 = meta.data[i]._model.x;
var y = meta.data[i]._model.y;
3reactions
shivabhusalcommented, Aug 8, 2017

Here is an example Codepen. Hope it will be helpful.

https://codepen.io/shivabhusal/pen/YxNGQN?editors=0010

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to find, highlight and label a data point in Excel scatter plot
The tutorial shows how to identify, highlight and label a specific data point in a scatter chart as well as how to define...
Read more >
Plot X and Y Coordinates in Excel - EngineerExcel
If you have a scatter plot and you want to highlight the position of a particular data point on the x- and y-axes,...
Read more >
How to Spot Data Point in Excel Scatter Chart
Select the already created scatter chart. · Go to Design –> Select Data. · In the Select Data Source dialogue box, Click Add....
Read more >
Extract Values to Points (Spatial Analyst)—ArcGIS Pro
ArcGIS geoprocessing tool that extracts the cell values of a raster based on a set of point features.
Read more >
Getting Points Object at Specific Position in Scatter Plot Graph
It is a type of plot or mathematical diagram using Cartesian coordinates to display values for typically two variables for a set of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found