-
Hello I want to add commas to my chart labels. Like from 56789 to 56,789. I am using version 2.9.4 of Chart.js and version 0.7.0 of of the label plugin. Tried the formatter didn't work |
Beta Was this translation helpful? Give feedback.
Answered by
nsartor
Mar 24, 2022
Replies: 1 comment
-
@Samamoah I was able to get this to work using chartjs 3.0 and a regex. I know you're using 2x, but if you happen to upgrade this should do it. I never got it to work using datalabels: {
formatter: (value, ctx) => {
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
},
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
simonbrunel
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Samamoah I was able to get this to work using chartjs 3.0 and a regex. I know you're using 2x, but if you happen to upgrade this should do it. I never got it to work using
toLocaleString
which would have been much cleaner.