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 documentation is incorrect #7174

Open
Xyloking17 opened this issue Mar 2, 2020 · 8 comments
Open

minBarLength documentation is incorrect #7174

Xyloking17 opened this issue Mar 2, 2020 · 8 comments

Comments

@Xyloking17
Copy link

Xyloking17 commented Mar 2, 2020

I was having trouble getting the minBarLength to work. After looking online for a solution I found #6212. In there Everybody was using the minBarLength in the scales options. I tried it out and this works, but in the documentation it shows the property being used in the dataset object

@benmccann
Copy link
Contributor

What version of Chart.js are you using? I believe if you're using the latest (2.9.3) it should work in either location

@Xyloking17
Copy link
Author

@benmccann I'm currently using version version 2.8.0 so I'll give it a try in 2.9.3 and see if it works

@aldipower
Copy link

aldipower commented Apr 19, 2020

Cannot get the minBarLength setting to work to, it just doesn't have any effect. I am using 2.9.3 and having the option in the dataset configuration.

minBarLength
This image illustrates the problem. The February month should be shown with a minBarLength of 2 pixels set in my dataset config. I tried other places like the scales config too..

This issue should be reopened:
#6212

@fds-github
Copy link

I believe that minBarLength makes a small bar starting at zero in the same direction as the sign of the value (in the positive direction if the value is zero). This can cause the bar to not show up in a couple of situations:

  • Aldipower's example, where 2 pixels is probably well less than the length that is necessary to hit 22 on the Y axis. A workaround is to include zero in the scale, perhaps via beginAtZero. This changes the look of the chart, but maybe that's better than showing a small bar at 22 when the actual value is probably well below that. Maybe some kind of arrow indicating that the value is "somewhere down there" could be shown?
  • My problem, where all my values are negative or zero, so the bar is above zero and so is clipped. The workaround I'm using is to set a small positive suggestedMax. It would be nice to instead have a fix where the minibar went in the negative direction for this case, as discussed in Make minBarLength work for data that's only <= 0 #6982.

@etimberg
Copy link
Member

It seems the problem here is that minBarLength always increases the size for 0 on the value axis. In https://jsfiddle.net/174aquk2/ it should apply from the base value to ensure that the middle bar appears.

@kurkle I think this should be an easy fix. Thoughts?

@kurkle
Copy link
Member

kurkle commented Oct 18, 2020

I think this one is more related to the beginAtZero, that we already changed to default for true for bar charts.
The minBarLenght correctly applies, its just not visible.

image
I'd think the image above would be very misleading if the data was [23, 0, 25]

@kurkle
Copy link
Member

kurkle commented Oct 18, 2020

Anyway, it would still be feasible to have a visible bar when there is a value even when beginAtZero is false.

minBarLenght could be used to figure out the amount a scale needs to "pad" itself to some direction.

There are some other use cases where I would need a scale to have a certain max value and and a certain amount of pixels to that.

So I'd tend to move this problem to the scale somehow.

@etimberg
Copy link
Member

This is much closer with v3.7.1 but still requires one extra setting to manually set the base value of the dataset to the minimum y axis value. https://jsfiddle.net/2bw8gv0y/

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

No branches or pull requests

6 participants