Chart.js: Make minBarLength work for data that's only <= 0

Created on 18 Jan 2020  ·  8Comments  ·  Source: chartjs/Chart.js

Feature Proposal

If I set minBarLength = 1 and I have a bar chart with data [0, 12.5], the first bar will be displayed as a very short bar:

Screenshot 2020-01-18 at 10 19 32

If, however, my data is [0, -12.5], the first bar is invisible:

Screenshot 2020-01-18 at 10 17 50

Feature Use Case

This would be great for bar charts that may display only data thats <= 0.

enhancement

All 8 comments

This is how the minBarLength is drawn right now:
B0CCF0BE-C7CA-41C2-BDB5-ED872A227EC0

This is what I imagine might be better, although I feel that this might be rather complex to implement:
6D818D1E-BD7A-4771-AA94-13551A4D4AB4

PS: This is weird: on desktop, the photos are rotated by 90° but not on mobile.. apologies for that

Seems like its the opposite in master compared to latest

The behavior on latest seems correct to me. The behavior on master does not

Both seem incorrect to me, minBarLength should be min length in any direction.

Isn't that what it is on latest? I don't understand what exactly is wrong about it

Oh, I had messed with the pen. it had '-0.001' onstead of 0.

For the behaviour on master, seems like we need to decide what to do when the value is the base value.

I think the most intuitive would be:

  • base is value scale start: positive
  • base is value scale end: negative
  • base is in the middle (the samples above): go positive

@benmccann @kurkle how do you feel about solving this for v3? I think we should because it's gotten worse than v2.9.3

When the base is in the middle, how about half above the base, half below?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gabrieldesouza picture gabrieldesouza  ·  3Comments

SylarRuby picture SylarRuby  ·  3Comments

JAIOMP picture JAIOMP  ·  3Comments

akashrajkn picture akashrajkn  ·  3Comments

lbowers picture lbowers  ·  3Comments