Chart.js
Chart.js copied to clipboard
How could I take the position of points on line chart?
Does anyone know how to get the location of points on the canvas from the lineChart? I need to draw a line between 2 data points. And I want to use something like this: `ctx.beginPath();
ctx.moveTo(520, yValue); //from point A
ctx.lineTo(520, 90); // to point B`
In order to draw the line. Problem is, I need the position of each point A and point B on the canvas. and I don't know how to take them.
I think something like this will work:
var meta = chart.getDatasetMeta(datasetIndex);
var point = meta.data[index];
var x = point._view.x;
var y = point._view.y;
@etimberg Thanks for your help and sorry for the late response. This solution solves my problem.