Highstock共享工具提示此索引

Highstock Shared Tooltip This Index

本文关键字:索引 工具提示 共享 Highstock      更新时间:2023-09-26

我必须使用共享的格式化工具提示,我如何获得点的索引我悬停在?我已经尝试了其他关于堆栈溢出的解决方案,但都不起作用。

tooltip: {useHTML: true, shared: true, formatter: function (tooltip) {
// where the hell is it!
var nodes = this.points;}}

在共享工具提示的formatter回调中,您将无法区分哪个点被悬停过,因此您无法直接获得该点的索引。然而,查找的点被存储为chart.hoverPoint.

formatter: function(tooltip) {
    // where the hell is it!
    var nodes = this.points,
            current = nodes[0].series.chart.hoverPoint;
    console.log(current, current.series.name);
    return current.series.name;
  }

示例:http://jsfiddle.net/g7gkuf4s/3/