Change Y Axis Value to Integer (no decimal values) in AmCharts

Gedalya picture Gedalya · Dec 5, 2013 · Viewed 7.7k times · Source

I have a chart in AmCharts that reflects integer values; as such I want the value in the Y Axis to also be integers however they are showing up as floating point. I have read through documentation and found reference to: numberFormatter with the following syntax:

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

Changing the precision does not seem to have an impact. I've seen suggestions at setting it to 0 would work for removing the value after the decimal but it does not. I have also read that setting precision to -1 inhibits rounding which confuses me as to what precision is used for.

I am using AmCharts version 2.9.3. I have found that there is a bug where numberFormatter is ignored in this version (pre 2.11) when usePrefixes was set to true however that is not the case.

I have found references to a parameter called: digits_after_decimal

However the references I found were for much older versions of AmCharts and the reference was for this parameter in a config file; and I do not see a reference for this in my version.

I have done quite a bit of research and am looking for any pointers as to what I am doing wrong as I know this is simply a misunderstanding of the API. I have also been toying with a JSFiddle example from AmCharts site:

http://jsfiddle.net/amcharts/zu9nW/

Answer

Gedalya picture Gedalya · Dec 5, 2013

I have found a solution. There are custom sections for updating qualities of both the y and x axis; in this case for the y axis, adding the following will represent only integers for the value column which on my graph was the y axis.

var valuesAxis = new AmCharts.ValueAxis();

valuesAxis.integersOnly = true;