Skip to content

Skip zeroline when negative sizes are present on positive base and vice versa #4714

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

Merged
merged 6 commits into from
Apr 6, 2020

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Mar 30, 2020

Fixes #4701 for bar and waterfall.

@plotly/plotly_js

 - no zero line sometimes needed with positive base and negative value
 - add test
@archmoj archmoj added bug something broken status: reviewable labels Mar 30, 2020
@@ -512,7 +512,7 @@ function setBaseAndTop(sa, sieve) {
pts.push(top);
if(bar.hasB) pts.push(base);

if(!bar.hasB || !(bar.b > 0 && bar.s > 0)) {
if(!bar.hasB || !(bar.b > 0 && bar.b + bar.s > 0)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Per #4701 (comment) I'm really curious if there's anything wrong with just:
if (!bar.hasB || !bar.b)
or maybe even
if (!bar.b)
depending on what these values are.

If you negate all base and size values - so all top and bottom values are <0 - we should also not draw the axis to zero. And if there are already values on both sides of zero, the tozero: true flag is irrelevant.

Also: there's similar logic down in normalizeBars ~line 700 that probably needs updating as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now added logic & tests to handle negative case similar to the positive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Per #4701 (comment) I'm really curious if there's anything wrong with just:
if (!bar.hasB || !bar.b)
or maybe even
if (!bar.b)
depending on what these values are.

That would change bar_attrs_overlay & bar_attrs_group baselines.

@archmoj archmoj changed the title Skip zeroline when negative sizes are present on positive base Skip zeroline when negative sizes are present on positive base and vice versa Mar 31, 2020
Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃 very nice!

@archmoj archmoj merged commit 30f3ddc into master Apr 6, 2020
@archmoj archmoj deleted the bar-with-base-tozero branch April 6, 2020 19:04
@archmoj archmoj added this to the v1.54.0 milestone Apr 20, 2020
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

Successfully merging this pull request may close these issues.

autorange should not display zero line for certain bars with positive base and negative value
2 participants