Daniel Alexiuc
Daniel Alexiuc

Reputation: 13240

HighCharts: Update the series name label dynamically

I've been able to dynamically update the data on the charts using addPoint(), but am having trouble updating any other parts of the graph.

I'd like to update the series name.

enter image description here

I've tried setting the series.name directly in javascript, and I've tried calling series.setOptions() with the updated options (which includes the name). But the graph does not update, even if I call chart.redraw().

Upvotes: 1

Views: 6894

Answers (1)

Mark
Mark

Reputation: 108567

Not optimal but after changing the series name, you could modify the legend directly by manipulating the SVG (assumes jQuery):

$($('.highcharts-legend-item tspan')[0]).text('SomeOtherLabel')

Or better yet, using the Highcharts API:

$(chart.legend.allItems[0].legendItem.element.childNodes).text('Hi Mom')

Upvotes: 2

Related Questions