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

minBarLength Stacked bar chart not working #10664

Closed
nabenzine opened this issue Sep 12, 2022 · 7 comments · Fixed by #10766
Closed

minBarLength Stacked bar chart not working #10664

nabenzine opened this issue Sep 12, 2022 · 7 comments · Fixed by #10766

Comments

@nabenzine
Copy link

nabenzine commented Sep 12, 2022

Hello there,

This is an old annoying bug, that still exists in latest version, the minBarLength doesn't work as expected in case of Stacked bar,
the minBarLength doesn't apply to each dataset, but instead it applies to the whole bar, which cause overlapping, between bars.

Please fix this, it's really unusable for many usecases.

You'll find bellow a reference with the illustrated problem.

Thank you for your hard work.

=======================================
Originally posted by @tomzag in #5741 (comment)

There seems to be a problem with stacked bar charts.

Here for example a horizontal stacked bar chart:
Bildschirmfoto 2020-12-24 um 13 14 44

The minBarLength works but the stacked version isn't respecting it and the bars overlap.

@Kit-p
Copy link
Contributor

Kit-p commented Oct 1, 2022

Hi @nabenzine, would you please kindly share a minimal chart configuration to reproduce this issue? I would like to see if I can help fix this problem!

@nabenzine
Copy link
Author

nabenzine commented Oct 4, 2022

Hi @nabenzine, would you please kindly share a minimal chart configuration to reproduce this issue? I would like to see if I can help fix this problem!

Hi @Kit-p, thank you for your message, I am a bit hopeless, I created a codesandbox that illustrate the problem codesandbox

image

Thank you in advance !

@Kit-p
Copy link
Contributor

Kit-p commented Oct 4, 2022

@nabenzine Thank you, will take a look at it.

Meanwhile, I would like to confirm with you (and the Chart.js maintainers if any of you is reading) the expected behavior.

If minBarLength also affects the offset of the bars, we are likely to end up with 3 bars of 1 longer than 1 bar of 10, which is not ideal for a visual comparison of the total of each group.

Should we just fix the offset or add another property to optionally enable the current behavior?

@kurkle
Copy link
Member

kurkle commented Oct 4, 2022

I don't think current behavior is valid for any use case, so my vote is for just fixing it, without new options.

@Kit-p
Copy link
Contributor

Kit-p commented Oct 6, 2022

@nabenzine I have made some progress in this. Here is a codesandbox with my version of Chart.js.

I would appreciate if you could help play around with it and report any problem you notice, thank you!

@nabenzine
Copy link
Author

@nabenzine I have made some progress in this. Here is a codesandbox with my version of Chart.js.

I would appreciate if you could help play around with it and report any problem you notice, thank you!

That's amazing, thank you very much, It's seems to work fine except for label, I couldn't make them work as usual with the chartjs-plugin-datalabels

image

Labels are not centered as in my initial codesandbox, maybe I am doing something wrong, Here is the
codesandbox

@Kit-p
Copy link
Contributor

Kit-p commented Oct 6, 2022

That's weird, but it is expected that the datalabel plugin does not work with a local version of Chart.js. You installed an actual release of Chart.js as a workaround, which could be the cause of the labels not being in center, not 100% sure about that though.

As there is no test on the integration with other plugins, this is quite hard for me to debug. I will finish off the remaining work in these 2 days and push it to my fork, so we can see how it works when properly installed as a node module.

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

Successfully merging a pull request may close this issue.

3 participants