How to get next point in Highcharts tooltip

2019-02-18 23:38发布

问题:

how can I access to the next point of the series from the tooltip formatter. Because I want to do a sum between both points. Like this.y + next.y.

But I don't know how to have an access to the next point.

If someone have an answer. Thanks

回答1:

This need to be done in a few steps:

  • get x-index according to x-value: var index = this.series.xData.indexOf(this.x);
  • now get y-value: var nextY = this.series.yData[index+1];

And all you need to do is to sum values, like this: var sum = this.y + nextY;.