wergeld
wergeld

Reputation: 14442

Remove HighChart Rendered Button

I am using the chart.renderer to add a button via:

    normalState = new Object();
    normalState.stroke_width = null;
    normalState.stroke = null;
    normalState.fill = null;
    normalState.padding = null;
    normalState.r = 3;

    hoverState = new Object();
    hoverState = normalState;
    hoverState.fill = 'red';

    pressedState = new Object();
    pressedState = normalState;
    custombutton = chart.renderer.button('Reset Chart', 74, 10, function () {
        chartMainsetChartInit(chartSeries);
    }, null, hoverState, pressedState).add();

This does show the button and it does fire the function I need. However, I am unable to remove this button. I have tried:

chart.renderer.button(custombutton).destroy();

And

chart.renderer.button('Reset Chart').destroy();

Neither throw errors but the button is not removed. How can I remove the button?

Upvotes: 0

Views: 791

Answers (1)

wergeld
wergeld

Reputation: 14442

I was over thinking it. Solution is to make the button object scoped correctly and then call:

custombutton.destroy();

This works flawlessly.

Upvotes: 1

Related Questions