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

Tick NumberFormat not working for 0 #11905

Open
SosthenG opened this issue Sep 24, 2024 · 0 comments
Open

Tick NumberFormat not working for 0 #11905

SosthenG opened this issue Sep 24, 2024 · 0 comments

Comments

@SosthenG
Copy link

Expected behavior

The 0 value is formatted as the other ticks when a "format" config is provided in scales.y.ticks.format

Current behavior

The 0 is never formatted

Reproducible sample

https://codepen.io/SosthenG/pen/rNXNPPL

Optional extra steps/info to reproduce

No response

Possible solution

Issue is here :

numeric(tickValue, index, ticks) {
if (tickValue === 0) {
return '0'; // never show decimal places for 0
}

While it makes sense to prevent the 0 value to have any decimal, it also prevent the call to formatNumber. I think it should be possible to achieve the same by still calling the formatNumber in any case but forcing the minimumFractionDigits to 0 if the value is 0.

Context

I want the 0 to be formatted the same as other values because otherwise it does not look well when using percent or currency values to have juste "0" without the unit.

chart.js version

4.4.2

Browser name and version

No response

Link to your project

No response

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

1 participant