You must be logged in to post your query.
Home › Forums › Chart Support › dataPointIndex of scatter
I want to know dataPointIndex of scatter chart. In the example below, the alert message of first point is “scatter, dataPoint {x:10, y:34}, index=0” However, the actual index of “{x:10, y:34}” is 1. I guess that the dataPoint is sorted. Is there a way to get the original index?
var chart = new CanvasJS.Chart(“chartContainer”, { title:{ text: “Attaching Mouse Over event on dataSeries” }, data: [ { type: “scatter”, mouseover: onMouseover, dataPoints: [ { x: 20, y: 45}, { x: 10, y: 34}, { x: 30, y: 19 }, { x: 40, y: 75 }, { x: 50, y: 15 }, { x: 60, y: 60 }, { x: 70, y: 48 }, { x: 80, y: 04 }, { x: 90, y: 35} ] } ] }); chart.render();
function onMouseover(e){ alert( e.dataSeries.type+ “, dataPoint { x:” + e.dataPoint.x + “, y: “+ e.dataPoint.y + ” }, index=” + e.dataPointIndex ); }
dwpark,
As of we dataPoints are automatically sorted in case of scatter & bubble charts. We’ll consider changing this behavior in upcoming versions.
As a workaround you can store the index value of dataPoints yourself and access them inside the event handler.
Here is an example.
— Sunil Urs
You must be logged in to reply to this topic. Login/Register