Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author methnen

    (@methnen)

    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.

    Thread Starter ozgurerdogan

    (@ozgurerdogan)

    I found this but not sure how to implement. Can I use functions.php for it.

    Plugin Author methnen

    (@methnen)

    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.

    Thread Starter ozgurerdogan

    (@ozgurerdogan)

    Can not believe this is not avaliable ??

    Thread Starter ozgurerdogan

    (@ozgurerdogan)

    Did you also see this:
    https://stackoverflow.com/a/43457756
    They seem to have it done.

    Thread Starter ozgurerdogan

    (@ozgurerdogan)

    How can I add those options: in functions.php. Can you please show me a hint?

    Thread Starter ozgurerdogan

    (@ozgurerdogan)

    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?

    Plugin Author methnen

    (@methnen)

    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:

    https://github.com/methnen/m-chart-highcharts-library/

    Thread Starter ozgurerdogan

    (@ozgurerdogan)

    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?

    Plugin Author methnen

    (@methnen)

    I’d ask Highsoft. They’re the only ones who can say for sure if what they do would require a commercial license.

    Plugin Author methnen

    (@methnen)

    Closing as I believe this has been dealt with as well as possible at this point.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Number formatting.’ is closed to new replies.