I'm using "Time data with irregular intervals" chart of Highcharts. As you know when mouse moves over points of line the formatter function runs and shows some information. I want to know index of the point that mouse moves over it. So if mouse moves over first point of the line, tooltip shows "1" and the second point shows "2" and so on. thnx.
This worked for me using v2.2:
this.series.data.indexOf( this.point )
One way is to pre-process the data to contain a property with the index. In the Snow-depth example you could do a preparation like this:
function prepare(dataArray) {
return dataArray.map(function (item, index) {
return {x: item[0], y: item[1], myIndex: index};
});
};
to convert the array of [x, y]
to be an object like { x: x, y: y, myIndex: i}
. Then its easy to pick up that index in the formatter with:
formatter: function() {
return 'point ' + this.point.myIndex;
}
Example on jsfiddle
For the record your can do it directly in a nice way
It is store in:
this.points[0].point.x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With