Highcharts在堆积条的中间定位工具提示

问题描述 投票:1回答:1

我一直在尝试使用工具提示定位器在每个堆叠条的中间而不是右侧获取工具提示,但我无法找到任何可用于计算适当点的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/

javascript highcharts tooltip stacked
1个回答
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'
© www.soinside.com 2019 - 2024. All rights reserved.