react-plotly.js icon indicating copy to clipboard operation
react-plotly.js copied to clipboard

Issue with axis autorange: state self-mutates 'reversed' -> true

Open dougdenn opened this issue 6 years ago • 1 comments

As far as I understand, Plotly's axis reversal works by setting autorange to a string value of 'reversed' (with the other options being true for non-reversed autorange, and false for no autorange). After setting this, Plotly will autoscale the axis with range[0] and range[1] of the axis swapped.

The problem is, it seems like after setting autorange -> 'reversed', react-plotly mutates autorange back to true after doing the range reversal. So, there is no way to un-reverse the autorange without setting it first to false, then true.

What I think should happen: Step 1: autorange true -> 'reversed' Step 2: autorange 'reversed' -> true //can toggle axis reversal

What actually happens: Step 1: autorange true -> 'reversed' -> true //last step being done automatically by react-plotly Step 2: autorange true -> true //doesn't toggle axis reversal b/c no state change

dougdenn avatar Aug 22 '19 22:08 dougdenn

Was looking at this issue more this morning - here's a CodePen that shows the problem.

https://codepen.io/dougleville/pen/BaBpxXq

It's interesting because it's clearly keeping track internally somehow that the axis should stay reversed, because despite onUpdate() returning autorange: true, when you zoom in and then double-click to return to autorange, the axes are still reversed.

dougdenn avatar Aug 23 '19 14:08 dougdenn