简体   繁体   English

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

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

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? 那么有没有办法改变传奇标签名称?

You can use update() function 您可以使用update()函数

 chart.legend.allItems[0].update({name:'aaa'});

http://jsfiddle.net/bL5ZM/1/ http://jsfiddle.net/bL5ZM/1/

You could also use 你也可以用

chart.series[0].update({ name: "hello"});

http://jsfiddle.net/bL5ZM/149/ http://jsfiddle.net/bL5ZM/149/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM