【问题标题】:Always position Highcharts tooltip on top with respect to the marker point始终将 Highcharts 工具提示相对于标记点放在顶部
【发布时间】:2019-01-24 19:20:53
【问题描述】:

总是将工具提示放在点的顶部很热门?

有没有办法将 Highcharts 工具提示始终定位在悬停点的顶部?我尝试使用工具提示 > 定位器来固定位置,但如果点在图表边缘,则工具提示会被剪切。

positioner: function(labelWidth, labelHeight, point) {
    var tooltipX = point.plotX + 20;
    var tooltipY = point.plotY - 30;
    return {
        x: tooltipX,
        y: tooltipY
    };
}

1.没有定位器块:

2。使用定位器块:

3.所有情况下的预期结果:

【问题讨论】:

    标签: highcharts


    【解决方案1】:

    你可以包装getPosition方法并重新计算工具提示位置:

    var H = Highcharts;
    
    H.wrap(H.Tooltip.prototype, 'getPosition', function(proceed, boxWidth, boxHeight, point) {
        var result = proceed.apply(this, Array.prototype.slice.call(arguments, 1));
    
        if (result.y > point.plotY) {
            result.y = result.y + (point.plotY - result.y);
        }
        return result;
    });
    

    现场演示:http://jsfiddle.net/BlackLabel/156nydh4/

    文档:https://www.highcharts.com/docs/extending-highcharts/extending-highcharts

    【讨论】:

      猜你喜欢
      • 2015-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-19
      • 1970-01-01
      相关资源
      最近更新 更多