在Highcharts中,图表变化时如何移动注释?

In Highcharts, how to move annotations along with the chart when it changes?

Highcharts 是否允许您确保注释在调整图表大小时随图表一起移动(如果图表显示在较小的屏幕上,或者如果它是突出显示的图表,则有必要)。如果是这样,有人可以告诉我如何做到这一点,因为我需要这个来满足我的一个要求。

这是我的注释代码:

chart: {
  type: 'bubble',
  zoomType: 'xy',
  events: {
    load() {
      const chart = this;
      chart.renderer.text('← More Disruptive', 290, 20)
      .attr({ zIndex: 10 })
      .css({ fontSize: '12px', color: '#666666'})
      .add();
      chart.renderer.text('Less Disruptive →', 440, 20)
      .attr({ zIndex: 10 })
      .css({ fontSize: '12px', color: '#666666'})
      .add();
      chart.renderer.text('Greatly Decreased ↑', 685, 140)
      .attr({ zIndex: 10 })
      .css({ fontSize: '12px', color: '#666666'})
      .add();
      chart.renderer.text('Greatly Increased ↓', 688, 205)
      .attr({ zIndex: 10 })
      .css({ fontSize: '12px', color: '#666666'})
      .add();
    }
  }
}

https://jsfiddle.net/samwhite/jy4dcwb7/

如果您 link 一个点的注释:http://jsfiddle.net/BlackLabel/sfo3L704/ 或将其附加到模拟点:http://jsfiddle.net/BlackLabel/4ouwn19j/ 它将响应。

    annotations: [{
        labels: [{
            point: {
                xAxis: 0,
                yAxis: 0,
                x: 3,
                y: 6
            }
        }]
    }]

在其他情况下,您需要在每次调整大小后计算注释的位置(例如使用 chart.redraw 事件)。


API参考:https://api.highcharts.com/highcharts/annotations.labels.point