Highcharts:如何动态更新标签内的文本?

Highcharts:如何动态更新标签内的文本?,highcharts,Highcharts,我有这样的代码:我可以成功地更改标签的相关颜色和字体 我缺少的是,我希望能够更新标签本身的文本 我尝试了以下代码: // Update the label thischart.currentAnnotation.update({ labels: [{ text: fontText, //this line is not working backgroundColor: fontBackgroundColor, style: { fontS

我有这样的代码:我可以成功地更改标签的相关颜色和字体

我缺少的是,我希望能够更新标签本身的文本

我尝试了以下代码:

// Update the label
thischart.currentAnnotation.update({
  labels: [{
    text: fontText, //this line is not working         
    backgroundColor: fontBackgroundColor,
    style: {
      fontSize: fontSzie,
      color: fontColor
    }
  }]
});
thischart.currentAnnotation.labels[0].update({
  text: fontText
});
我还尝试了代码:

// Update the label
thischart.currentAnnotation.update({
  labels: [{
    text: fontText, //this line is not working         
    backgroundColor: fontBackgroundColor,
    style: {
      fontSize: fontSzie,
      color: fontColor
    }
  }]
});
thischart.currentAnnotation.labels[0].update({
  text: fontText
});
我在类似的线程中发现了更多的组合(包括
attr
属性),但它们都不起作用


因此,我想知道,如何动态更新文本?

这个问题是由于您在标签创建过程中使用了
format
属性,并更新了
text
属性。文本被格式覆盖

    var onclick = function() {
        _self.chart.addAnnotation(Highcharts.merge({
                langKey: 'label',
                labelOptions: {
                    // format: labelTextForm.querySelector('#labelTextInput').value,
                    shape: 'rect'
                },
                labels: [{
                    text: labelTextForm.querySelector('#labelTextInput').value,
                    ...
                }]
            }, ...));
    };

现场演示:

API参考: