user2216475
user2216475

Reputation:

Highcharts: Change the Legend TItle on drilldown

I'm trying to have the legend title change when I drill-down to the next level of the data.

Currently, I'm using a click event to call a function which removes the existing series and adds new ones, followed by chart.redraw().

Is it possible to set the Legend title using .attr in this same function? I've seen a few examples that use this to change the y-axis or chart title, but I can't get it working for the legend title.

    function redrawLegend(legendtitle) {
    chart.legend.attr({
        text: legendtitle
        });
};

'legendtitle' is in this case a variable that I have stored with the drill-down data.

Upvotes: 2

Views: 4225

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

Use: chart.legend.title.attr({ text: 'aaa' });

Example: http://jsfiddle.net/ag6Wq/

Upvotes: 4

Related Questions