javascript Highcharts:图表创建后如何设置图例标签名称?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17168793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Highcharts: how to set legend label name after chart created?
提问by redexp
I need to change dynamically legend labels and I was surprised when I have not found method like chart.legend.setLabels()
我需要动态更改图例标签,当我没有找到类似的方法时,我感到很惊讶 chart.legend.setLabels()
I tried this
我试过这个
chart.legend.allItems[0].name = 'bla bla'
chart.legend.redraw()
nothing happend
什么都没发生
tried to change options
试图改变选项
chart.options.legend.labels[0].name = 'bla bla'
chart.redraw()
nothing happend
什么都没发生
So is there way to change legend label name?
那么有没有办法更改图例标签名称?
回答by Sebastian Bochan
You can use update() function
您可以使用 update() 函数
chart.legend.allItems[0].update({name:'aaa'});