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

Set the maximum width of categorical bars & boxes to category unit - case of categoryarray #5732

Merged
merged 4 commits into from
Jun 17, 2021

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented Jun 15, 2021

Fixes #5731.

@plotly/plotly_js

@nicolaskruchten
Copy link
Member

Behaviour looks good.

@nicolaskruchten
Copy link
Member

Interestingly, box and violin don't seem to suffer from this problem even on master ... normal?

@archmoj
Copy link
Contributor Author

archmoj commented Jun 16, 2021

Interestingly, box and violin don't seem to suffer from this problem even on master ... normal?

Positive. Thanks for checking.


this.distinctPositions = dv.vals;
if(dv.vals.length === 1 && width1 !== Infinity) this.minDiff = width1;
else this.minDiff = Math.min(dv.minDiff, width1);

var type = (opts.posAxis || {}).type;
if(type === 'category' || type === 'multicategory') {
this.minDiff = Math.min(1, this.minDiff);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This looks like a great solution, and simpler than the previous logic. My only question is whether there's actually a benefit of doing Math.min vs just minDiff = 1 in the (multi)category case? There's no way to specify input data that will result in non-integer positions here, is there?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good call. Set to one in 6e6bfa6.

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.

Co-authored-by: Alex Johnson <johnson.alex.c@gmail.com>
@archmoj archmoj merged commit ebf971e into master Jun 17, 2021
@archmoj archmoj deleted the fix5731-category-bar-width branch June 17, 2021 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bar widths and categoryarray
3 participants