Abiel
Abiel

Reputation: 5455

Reversing Highcharts Y-axis after the chart has been initialized

I originally asked this question on the Highcharts forum a few days ago but received no answer so let me ask it here:

I want to have a chart where I can toggle the 'reversed' property of the Y-axis after the chart has been initialized and then see the chart redrawn. My first thought was to put something like the following code inside of an event handler (say in response to a button click), but it doesn't seem to do anything.

chart.yAxis[0].reversed = !chart.yAxis[0].reversed;
chart.redraw();

Upvotes: 1

Views: 897

Answers (1)

Matthew Strawbridge
Matthew Strawbridge

Reputation: 20600

I don't think it's possible (see this forum post).

In particular, the last response on that post concludes with this:

I would suggest a workflow for your gui that updates a structure that keeps the options and then creates a new chart based on the options. The api we have has more of a focus on changing the data that is displayed than changing how the data is displayed.

So you might have to create two charts (one for each axis direction), only display one of them at a time, and toggle between them at runtime.

Update:

The accepted answer on this duplicate question suggests it is possible by doing this:

chart.yAxis[0].update({
    reversed: !reversed
});

Upvotes: 1

Related Questions