Number formatting.
-
I need to format numbers in a format of xxx.xxx.xxx,xx Is that possible with Charts.js
-
I don’t believe Chart.js has built in comma decimal support.
I tried a number in that format inside of a chart and it does not appear that Chart.js knows what to do with it.
I found this but not sure how to implement. Can I use functions.php for it.
That adds commas into the tooltip display. It does not sadly allow for the commas to exist in the actual data. So you’d have to enter the data in with decimals and then use that to flip it around on the display end. But even then it would only affect the tool tips.
I don’t think that’s an actual workable solution sadly.
It’s a workaround and not even one that fixes all of the places where the numbers get displayed.
Can not believe this is not avaliable 🙁
Did you also see this:
https://stackoverflow.com/a/43457756
They seem to have it done.How can I add those options: in functions.php. Can you please show me a hint?
I can insert value 123.456 fine but when I add 123.456.789 it does not even show it. Could be something related to locate settings?
Seems like that might work. If I’m understanding it right, it still looks like you’d have to enter the data in the xxx,xxx,xxx.xx format. But that would flip the display of it around to use commas in the decimal place.
They’re using another library to handle formatting rather than trying to just do a string replacement which is good honestly but you’ll need to include it in the page as well.
As for implementing it inside the plugin you’d want to probably call the code using an action hook.
Maybe this one: m_chart_after_chart_args
Then you could modify the chart settings to use the library when rendering the numbers.
Still yes, pain in the neck Chart.js doesn’t already support this stuff natively.
Chart.js is still fairly young I think and it’s just missing some features like this. Highcharts already includes native comma decimal support. If you aren’t working on a commercial project that would probably be an easier choice:
Even I read their web site for licensing. I could be sure if I need to buy license.
The web site I am making is a organisation and not a company. But they are providing some services and earn money. And they want to simple publish some stats on their site as chart. Do you think it need license?I’d ask Highsoft. They’re the only ones who can say for sure if what they do would require a commercial license.
Closing as I believe this has been dealt with as well as possible at this point.
The topic ‘Number formatting.’ is closed to new replies.