Skip to content

Rangemode tozero has odd behavior with only negative points in scatter plot #798

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mboorstin opened this issue Jul 30, 2016 · 4 comments
Closed
Labels
bug something broken

Comments

@mboorstin
Copy link
Contributor

mboorstin commented Jul 30, 2016

Repro cases: http://codepen.io/anon/pen/QEBOzQ

I've encountered two odd behaviors when a scatter plot with an axis set to rangemode: 'tozero' has only negative data points. If there is only a single data point, the axis direction will be reversed and the inital range won't go all the way to the point (it looks like it's 1 unit away from the point; you can scroll to find the point at the correct coordinates). If there are multiple data points, the axis direction will be correct and both points will be within the initial range, but the initial range won't go to zero. I've included examples of these as the first and second graphs in the Codepen. I've also included examples of bar charts as the third and fourth graphs to show what I think is the correct behavior.

If this is indeed a bug I'm happy to work on a patch to fix it.

@etpinard etpinard added the bug something broken label Aug 1, 2016
@etpinard
Copy link
Contributor

etpinard commented Aug 1, 2016

Thanks very much for this very detailed report.

The autorange code is pretty old and not that well tested so I'm not sure what exactly rangemode: 'tozero' should do for scatter traces with negative values.

Generalising non-default rangemode to negative values would be great addition to the library. But we should first solidify our testing suites.

Here are the (only) two image test we have for non-default rangemode at the moment:

  • axes_range_mode - mock | img
  • autorange-tozero-rangemode - mock | img

The autorange computations are made in Axes.getAutoRange and rely on Axes.expand which is called from the trace modules (e.g. here for bar traces). Both these routine aren't tested in isolation yet (in axes_test.js). We should do this before moving on this fixing the issue you're pointed here.

@mboorstin
Copy link
Contributor Author

OK. I'll take a crack at adding some Jasmine tests in axes_test.js with what I think is reasonable behavior.

@mboorstin
Copy link
Contributor Author

@etpinard can you take a look at #813? Thanks!

@etpinard
Copy link
Contributor

etpinard commented Aug 8, 2016

fixed by #813

@etpinard etpinard closed this as completed Aug 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

2 participants