是否可以自定义拆分工具提示位置?

时间:2016-12-27 07:12:55

标签: javascript highcharts

期望

共享系列具有独立位置工具提示

试过

根据Highcharts文档,我知道Highcharts.tooltip.positioner可以对工具提示进行一些自定义,但是当我搜索时,所有这些都是 un-split 工具提示。并且在拆分情况下失败,那么有没有可能自定义拆分工具提示位置?

http://jsfiddle.net/TabGre/fyxqsq4L/

UPD

每个点的工具提示位于其上方,就像positioner

一样
positioner: function () {
  return {
    x: this.plotX;
    y: this.plotY + 100;
  }
}

1 个答案:

答案 0 :(得分:1)

正如我在评论中提到的,目前定位器回调不会影响拆分工具提示。但是,可以覆盖负责渲染拆分工具提示的函数。它需要自己计算位置。

如果您希望分割工具提示位于左上角,就像fiddle一样 你需要用每个方框的所需位置覆盖Highcharts.Tooltip.prototype.renderSplit = function(labels, points)

  var yPos = 0;

            each(boxes, function(box, i) {
                var point = box.point,
                    series = point.series;

                // Put the label in place
                box.tt.attr({
                 //   visibility: box.pos === undefined ? 'hidden' : 'inherit',
                    x: (rightAligned || point.isHeader ?
                        //box.x :
                        0 :
                        point.plotX + chart.plotLeft + pick(options.distance, 16)),
                  //  y: box.pos + chart.plotTop,
                    y: yPos,
                    anchorX: point.isHeader ?
                        point.plotX + chart.plotLeft : point.plotX + series.xAxis.pos,
                    anchorY: point.isHeader ?
                        box.pos + chart.plotTop - 15 : point.plotY + series.yAxis.pos
                });
                yPos += box.size;
            });

示例:http://jsfiddle.net/tbguemvL/