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

zorder on overlayed subplots case of multiple traces in each subplot #7070

Closed
stephprobst opened this issue Jul 30, 2024 · 13 comments · Fixed by #7141
Closed

zorder on overlayed subplots case of multiple traces in each subplot #7070

stephprobst opened this issue Jul 30, 2024 · 13 comments · Fixed by #7141
Assignees
Labels
bug something broken cs customer success P1 needed for current cycle

Comments

@stephprobst
Copy link

stephprobst commented Jul 30, 2024

The in plotly.js 2.34.0 introduced zorder property does not work as expected. The following chart demonstrates the issue:

https://codepen.io/Djeramon/pen/VwJPXGr

image

The orange line is drawn on top, but it should be drawn behind the green and red line.

The issue seems to be related to the traces being linked to different y-axes. Once the axes are being linked to the same y-axis, the bug disappears.

@gvwilson gvwilson added the P2 considered for next cycle label Jul 30, 2024
@archmoj
Copy link
Contributor

archmoj commented Jul 30, 2024

Thanks for the report. This is a bug.

@archmoj archmoj added the bug something broken label Jul 30, 2024
@gvwilson gvwilson added P1 needed for current cycle cs customer success and removed P2 considered for next cycle labels Aug 9, 2024
@archmoj
Copy link
Contributor

archmoj commented Sep 5, 2024

@stephprobst in your codepen the third trace has a name saying the zorder is 3; but its zorder is actually is set to 2.
Since this is confusing, I thought you may want to adjust that?

@stephprobst
Copy link
Author

@archmoj : You're right. Thanks. I corrected it.

@archmoj
Copy link
Contributor

archmoj commented Sep 5, 2024

Thanks @stephprobst.
It looks like if you drop barmode: 'stack' or use barmode: 'overlay' or barmode: 'group'; the issue is still present.
Please confirm.

@stephprobst
Copy link
Author

@archmoj : Yes, I can confirm. The problem doesn't seem to be related to the used barmode.

@archmoj
Copy link
Contributor

archmoj commented Sep 5, 2024

@stephprobst I'm trying to replicate this issue by tweaking one of the minimal mocks we used for zorder and overlayed axis.
This codepen works as expected while using bars for first two traces and z order values similar to what you have in your original codepen.
Could you possibly help find what should be changed so that the bug appears?

@stephprobst
Copy link
Author

@archmoj : The problem sits with the assignment of the bars to the y-axes. If you remove all assignment information, the bug appears. In your current codepen version:

  {
   "type": "bar",
   "x": ["A", "B", "C", "D"],
   "y": [1, 2, 3, 4],
   "zorder": 1
  },
  {
   "type": "bar",
   "width": 0.6,
   "x": ["A", "B", "C", "D"],
   "y": [2, 3, 4, 1],
   "zorder": 2
  },

@archmoj
Copy link
Contributor

archmoj commented Sep 5, 2024

OK. So this is not related to combinations of bars and scatter as well.
Here is a minimal codepen which uses scatter traces only to help introduce this bug.
@stephprobst Please confirm.

@stephprobst
Copy link
Author

@archmoj : Yes, I can confirm, that the bug is present in the given codepen and that the root cause seems to be related to the assignment to the y-axes.

@archmoj
Copy link
Contributor

archmoj commented Sep 5, 2024

Thanks @stephprobst.
Now please update the issue title and description to better describe it.

@stephprobst stephprobst changed the title Zorder doesn't work as expected Zorder doesn't work as expected when using multiple y-axes Sep 5, 2024
@stephprobst
Copy link
Author

@archmoj : Done.

@archmoj archmoj changed the title Zorder doesn't work as expected when using multiple y-axes zorder on overlayed subplots case of multiple traces in each subplot Sep 5, 2024
@archmoj
Copy link
Contributor

archmoj commented Sep 5, 2024

@stephprobst I edited the title.
Also FYI this codepen with two traces in each overlayed subplot renders as expected. Please confirm.

BTW it appears in the original issue the bug appears when lower subplot has more traces in it.
That could likely be related to the way the z index is added to declare subplot on one another.
Investigating...

@stephprobst
Copy link
Author

@archmoj Yes, I confirm, that the linked codepen works as expected.

Thanks for your work on this.

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

Successfully merging a pull request may close this issue.

3 participants