redexp
redexp

Reputation: 5075

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()

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?

Upvotes: 5

Views: 20143

Answers (2)

Magnus O.
Magnus O.

Reputation: 528

You could also use

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

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

Upvotes: 1

Sebastian Bochan
Sebastian Bochan

Reputation: 37588

You can use update() function

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

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

Upvotes: 11

Related Questions