-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Implement alignmentgroup and offsetgroup #3529
Conversation
src/traces/bar/defaults.js
Outdated
// TODO make this work across matching axes too?!? | ||
// TODO should this work per trace-type? | ||
// one set for bar/histogram another for box/violin? | ||
// or just one set for all trace trace types? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does anyone here have a strong opinion about this?
Should alignmentgroup
and offsetgroup
work across trace types? Or should we match bar and histogram and box and violin groupings separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like making it work across trace types would be the most flexible - you can always just give different values to different trace types, which I guess is what the default would be. It's also probably what I'd expect as a user. It's an awfully weird use case, so not worth a huge effort, but if we omit it now and wanted to add it later it would be a breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bars above for counts (say) and boxes below for distributions? Seems not that weird to me :) kinda useful actually!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah good point. That would magically work if you have the same traces in each case, and in the same order... but break those assumptions (which could happen for good reasons) and you're back to manual alignment if we don't implement this cross-type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in e746b08
... as well as across trace types (confirmed behavior) to do so: - add getAxisGroup axis_ids.js util - mv alignmentgroup and offsetgroup coerce calls to crossTraceDefaults
@plotly/plotly_js this PR is now @archmoj could you review this one? |
Excellent PR 💃 |
All the new mocks in a codepen: |
@etpinard thank you for this feature! One minor issue is that traces do not re-layout when toggled (reproduced in your "mocks"). So the user cannot turn-off traces using the legend to view the remaining traces at a larger size. |
@arlowhite thanks, would you mind filing a bug report at https://github.com/plotly/plotly.js/issues/new ? |
resolves #3402 - at least the part listed in #3402 (comment)
In brief, this PR add two attributes
alignmentgroup
andoffsetgroup
to bar, histogram, box and violin traces. These attributes allow to have more control over how the cross-trace offset and width values are computed. Examining thebar-alignment-offset
mock is probably the best way to grasp what these new attributes do.cc @plotly/plotly_js and @nicolaskruchten - it would be nice if you could take a 👀 at the new mocks, thanks!
some TODOs:
alignmentgroup
andoffsetgroup
on matching axes, once Implementing matching axes #3506 is mergedalignmentgroup
andoffsetgroup
should do across trace types