Highcharts:如何在图表创建后设置图例标签名称

Highcharts: how to set legend label name after chart created?

本文关键字:设置 标签名 创建 Highcharts      更新时间:2023-09-26

我需要动态更改图例标签,当我没有找到像chart.legend.setLabels()这样的方法时,我很惊讶

I tried this

chart.legend.allItems[0].name = 'bla bla'
chart.legend.redraw()

没事发生

尝试更改选项

chart.options.legend.labels[0].name = 'bla bla'
chart.redraw()

没事发生

那么有办法改变传奇标签名称吗?

可以使用update()函数

 chart.legend.allItems[0].update({name:'aaa'});
http://jsfiddle.net/bL5ZM/1/

您也可以使用

chart.series[0].update({ name: "hello"});
http://jsfiddle.net/bL5ZM/149/