Highcharts 位置工具提示在堆叠条的中间

Highcharts position tooltip at the middle of stacked bar

我一直在尝试使用工具提示定位器在每个堆叠条的中间而不是右侧获取工具提示,但我一直无法找到任何可用于计算 x 的变量适当的点。

    tooltip: {
        positioner: function (labelWidth, labelHeight,point) {
            return {
                x: point.plotX - this.chart.hoverPoint.pointWidth,
                y: point.plotY + this.chart.plotTop - labelHeight
            };
        }
     }

这是一个代码笔,显示了它在最后一点上是如何失败的: http://jsfiddle.net/vw7ebd4k/1/

要计算工具提示位置,您可以使用 point.hlabelWidth。尝试这样的事情:

tooltip: {
    positioner: function (labelWidth, labelHeight, point) {
        return {
            x: point.plotX - point.h/2 + labelWidth/2,
            y: point.plotY
        };
    }
 }

要删除工具提示和点之间不必要的线,您可以使用 tooltip.shape 属性。

shape: 'rect'