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

Implement alignmentgroup and offsetgroup #3529

Merged
merged 5 commits into from
Feb 19, 2019
Merged

Conversation

etpinard
Copy link
Contributor

@etpinard etpinard commented Feb 8, 2019

resolves #3402 - at least the part listed in #3402 (comment)

In brief, this PR add two attributes alignmentgroup and offsetgroup 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 the bar-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:

  • Incorporate alignmentgroup and offsetgroup on matching axes, once Implementing matching axes #3506 is merged
  • Decide what alignmentgroup and offsetgroup should do across trace types

@etpinard etpinard added this to the v1.45.0 milestone Feb 8, 2019
// 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?
Copy link
Contributor Author

@etpinard etpinard Feb 8, 2019

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?

Copy link
Collaborator

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.

Copy link
Contributor

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!

Copy link
Collaborator

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.

Copy link
Contributor Author

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
@etpinard
Copy link
Contributor Author

@plotly/plotly_js this PR is now reviewable. We'll also need this one for 1.45.0.

@archmoj could you review this one?

@archmoj
Copy link
Contributor

archmoj commented Feb 19, 2019

Excellent PR 💃
@etpinard would you mind adding a codepen example to the PR description which may be helpful for the Q&A? @VeraZab

@etpinard
Copy link
Contributor Author

All the new mocks in a codepen:

https://codepen.io/etpinard/pen/mvoJoz

@etpinard etpinard merged commit 399d03b into master Feb 19, 2019
@etpinard etpinard deleted the offset-alignment-groups branch February 19, 2019 15:21
@arlowhite
Copy link

@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.

@etpinard
Copy link
Contributor Author

@arlowhite thanks, would you mind filing a bug report at https://github.com/plotly/plotly.js/issues/new ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Violins and Boxes in subplots oddly offset
5 participants