Number format with Amcharts Javascript

I solved the problem!

Into AmCharts.ready(function(){ put

chart.numberFormatter = {
  precision:-1,decimalSeparator:",",thousandsSeparator:""
};

All Number Format happens there!


var chart = AmCharts.makeChart("chartdiv", {
        [...]
        "numberFormatter": {
            "precision": -1,
            "decimalSeparator": ",",
            "thousandsSeparator": ""
        }
    });

If you need to format definite number:

var formatted = AmCharts.formatNumber(number, 
{
     precision: chart.precision,
     decimalSeparator: chart.decimalSeparator,
     thousandsSeparator: chart.thousandsSeparator
}, 2);

formatNumber(number, formatter, zeroCount)

Returns string formatter with the provided settings. Formatter is an object with precision, decimalSeparator and thousandsSeparator defined, like: {precision: 2, decimalSeparator: '.', thousandsSeparator: ','}; If you don't need to adjust precision set it to -1. zeroCount defines how many zeros should be added after comma (useful when formatting currencies).

Tags:

Amcharts