Skip to content

make offsetgroup work with barmode 'stacked' and 'relative' for bar traces #7009

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 27 commits into from
Oct 22, 2024

Conversation

my-tien
Copy link
Contributor

@my-tien my-tien commented Jun 1, 2024

This change makes it possible to create groups of stacked bar traces by setting barmode: "stacked" (or relative) on the axis and setting the same bar.offsetgroup for bars that should stack together. If no offsetgroup is defined, all bars at the same position are stacked together.

To summarize the interaction between axis.barmode and bar.offsetgroup after this change:

barmode 'group': bars without offsetgroup are automatically offsetted to appear next to each other. If some bars should appear at the same location, they should have the same offsetgroup.

other barmodes: bars without offsetgroup share the same position on the axis. If some bars should appear next to each other, they should have differing offsetgroups.

@gvwilson gvwilson requested a review from archmoj June 1, 2024 21:26
@archmoj archmoj added feature something new community community contribution status: reviewable labels Jun 3, 2024
@archmoj
Copy link
Contributor

archmoj commented Jun 6, 2024

@my-tien the mapbox baseline failures are fixed in #7019.
Please fetch upstream/master and then merge master into this pull request as well as into other PRs.

@archmoj
Copy link
Contributor

archmoj commented Jun 6, 2024

Getting closer.
Could you please investigate why the legendgroup mock renders differently compared to master?

my-tien added 4 commits June 7, 2024 14:40
Previously, all offsetgroups of different trace types were listed together, leading to undesired grouping interaction between different trace types.

Fixes failing baseline test "legendgroup".
@my-tien
Copy link
Contributor Author

my-tien commented Jun 7, 2024

Thanks @archmoj, I was able to restore the original looks of the legendgroup mock.

Two general questions to ensure that my changes make sense:

  1. I am a little bit unsure about the intended interaction between different trace types and their bar/scatter/box...modes. As far as I understand it, across traces we have the implicit behavior of "overlay" (with the exception of bars and histograms, because histograms also use barmode). Is this correct?

  2. How should alignmentgroup work exactly? The description in the documentation wasn't clear to me.
    And should alignmentgroups only matter among traces of the same type? I was experimenting with bars and boxplots in this codepen and saw some interaction. Boxplots become invisible when a bar shares its alignmentgroup:
    https://codepen.io/toffi-fee/pen/zYVaKrB

EDIT: I accidentally overwrote the content of the previously linked codepen with something else. Now I've recreated my example:

image

And here is the output of the same figure in my branch:

image

@archmoj archmoj requested a review from alexcjohnson June 7, 2024 13:22
@gvwilson gvwilson added the cs customer success label Jul 17, 2024
@gvwilson gvwilson changed the title For bar traces make offsetgroup work with barmode 'stacked' and 'relative' make offsetgroup work with barmode 'stacked' and 'relative' for bar traces Aug 9, 2024
@alexcjohnson
Copy link
Collaborator

@my-tien yes, that’s all correct, and thank you for catching my error, I will fix it above.

@my-tien
Copy link
Contributor Author

my-tien commented Sep 2, 2024

After spending way too much time trying to implement the implicit alignment and offsetgroups I figured that I don't actually need that for this PR.
As long as alignmentgroup and offsetgroup are set explicitly for all traces, they work as expected.

Regarding the two still failing baseline tests, the new images look to me more like what I would expect based on their mocks (ticks and grid at whole numbers). What do you think?

If you agree, I'll replace the baseline images with the new ones.

E.g. compare current baseline:

image

New image:

image

@archmoj
Copy link
Contributor

archmoj commented Sep 9, 2024

@my-tien Would you please fetch upstream/master and merge it into this branch?

@my-tien
Copy link
Contributor Author

my-tien commented Sep 10, 2024

done @archmoj

@archmoj archmoj requested a review from emilykl September 17, 2024 20:37
@archmoj
Copy link
Contributor

archmoj commented Oct 18, 2024

@my-tien Would you please fetch upstream/master and merge it into this branch again?
We are thinking to possibly include this feature in v3.1.0.
Thank you!

@archmoj
Copy link
Contributor

archmoj commented Oct 20, 2024

Thinking about this PR, it looks like a change that could possibly include in v3.0.0. @gvwilson
@my-tien Would you please merge master into this branch so that the tests pass?
Also please add draft log with a _change suffix.
Thank you!

@stephprobst
Copy link

@archmoj: I opened #7247 and rebased the branch on the latest master (I don't have access to my-tien's original branch). If you want, you can merge the new PR #7247 and close this one. I also added a draft log with _change suffix as requested.

@archmoj
Copy link
Contributor

archmoj commented Oct 22, 2024

@archmoj: I opened #7247 and rebased the branch on the latest master (I don't have access to my-tien's original branch). If you want, you can merge the new PR #7247 and close this one. I also added a draft log with _change suffix as requested.

Thanks @stephprobst I'm working on the same thing right now.

Copy link
Contributor

@archmoj archmoj left a comment

Choose a reason for hiding this comment

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

IMHO this "change" would be best to go into v3.0.0 because that could be considered a breaking change.
@alexcjohnson @gvwilson Do you agree?

@gvwilson
Copy link
Contributor

👍 on including this in 3.0 cc @LiamConnors we'll have to document the changed behavior

@gvwilson gvwilson added P1 needed for current cycle and removed P2 considered for next cycle labels Oct 22, 2024
@archmoj archmoj merged commit f0e508b into plotly:master Oct 22, 2024
1 check passed
@archmoj archmoj added this to the v3.0.0 milestone Oct 22, 2024
@my-tien
Copy link
Contributor Author

my-tien commented Nov 4, 2024

Many thanks for wrapping this up in my absence! <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community community contribution cs customer success feature something new P1 needed for current cycle
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants