Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix: display stacked bar with multiple x-Axis #12070

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 3 commits into from
Jun 5, 2025

Conversation

xavierleune
Copy link
Contributor

Hello everyone,

When you try to use stackedBars with multiple axes, the bars all render at the center of each axis chunk, so they're hidden by whichever bar is rendered last.

You can see a live example on codepen

screenshot

This pull request fixes this behavior. It counts the number of x axes and adjusts size and positions according to that number.

As this is my first pull request on this project, I may have missed something. If that's so, please tell me.

Have a nice day !

@LeeLenaleee LeeLenaleee added this to the Version 4.5.0 milestone May 7, 2025
@xavierleune
Copy link
Contributor Author

@LeeLenaleee thanks for the approval on the pipeline, do you have an idea why it failed ? It seems to be unrelated to my changes ?

@LeeLenaleee
Copy link
Collaborator

Sorry I have not had the time to give the tests a good look, I will try to look at it later this week

@xavierleune
Copy link
Contributor Author

@LeeLenaleee Hi there, do you we can retry the pipeline to see if it's still failing ? 🙏

@etimberg
Copy link
Member

etimberg commented Jun 5, 2025

@xavierleune I re-ran the pipeline to see. It looked like an image difference was detected. If it fails again, I'll look a bit more closely

@etimberg
Copy link
Member

etimberg commented Jun 5, 2025

ok, it failed again. The failing image is https://github.com/chartjs/Chart.js/blob/master/test/fixtures/scale.linear/grace/grace-beginAtZero.png

Not sure why that's failing only on ubuntu, but I wonder if the failure is due to the test having multiple x axes and now the image has changed. I'm a bit hesitant to change the tolerance on that test without knowing why it has changed. Are you able to run the test locally and see?

@xavierleune
Copy link
Contributor Author

thanks for the feedback @etimberg I'll have a look on that test 👍

@xavierleune
Copy link
Contributor Author

Ok I see, this test use: indexAxis: 'y' and this pull request focuses on x axis. I'll make the code more generic

@xavierleune
Copy link
Contributor Author

This should be correct now, I carefuly reviewed the tests and I think the other failures are only due to fonts mismatch and so... 🤞

src/controllers/controller.bar.js Outdated Show resolved Hide resolved
etimberg
etimberg previously approved these changes Jun 5, 2025
@LeeLenaleee LeeLenaleee merged commit 8ea47ca into chartjs:master Jun 5, 2025
6 checks passed
@xavierleune xavierleune deleted the fix/stack-multiple-axis branch June 5, 2025 15:28
@xavierleune xavierleune restored the fix/stack-multiple-axis branch June 5, 2025 15:28
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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.