Skip to content
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

Bug fix parcoords when all the data is zero #4082

Merged
merged 4 commits into from
Jul 26, 2019
Merged

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Jul 26, 2019

Fixes #4080 for parcoords, also
adds a condition check in Axes to avoid encountering log(0) in computing range-exponent.

@plotly/plotly_js

@archmoj archmoj added bug something broken status: reviewable labels Jul 26, 2019
@@ -839,7 +839,7 @@ function autoTickRound(ax) {
// 2 digits past largest digit of dtick
ax._tickround = 2 - Math.floor(Math.log(dtick) / Math.LN10 + 0.01);

var maxend = Math.max(Math.abs(rng[0]), Math.abs(rng[1]));
var maxend = Math.max(Math.abs(rng[0]), Math.abs(rng[1])) || 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I'm not a fan of this. We shouldn't have to patch this deep in axes.js. If cartesian axes don't need this || 1 fallback, parcoords shouldn't need it.

Could you help understand why we need to log a range value of 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could simply remove this from here. But I thought we should check for that to avoid log(0).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha I see, fde0d32 is enough to fix the problem. Sorry for the confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That should be enough. Do you want me to undo 765ca5a?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If maxend is 0 here, it leads to a pretty serious malfunction for this routine. Just mocking it to 1 isn't really the behaviour we want. In fact, the fallback is just there to not make Math.log blowup. Cartesian (and polar and maybe other axes) ranges are sanatised during ax.cleanRange, so maxend=0 never happens and the fallback is never used, so I'd be ok with dropping the fallback.

That said, since we're starting to reuse the more of the Axes logic, I think it would be best to log and error using Lib.error - similar to

Lib.error('tickFirst did not converge', ax);

So @archmoj you could just drop it, or drop it and add a Lib.error when maxend === 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@etpinard thanks for your review.
Dropped condition check of Axes in 096ed73.

@archmoj archmoj added the regression this used to work label Jul 26, 2019
@etpinard
Copy link
Contributor

Thanks very much !! 💃 💃

@archmoj archmoj merged commit 92fc203 into master Jul 26, 2019
@archmoj archmoj deleted the fix4080-parcoords-all-zero branch July 26, 2019 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken regression this used to work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Parcoords plot causes out of memory error or browser hang if data is all zeroes
2 participants