6

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/

Gedalya
  • 899
  • 4
  • 16
  • 28

3 Answers3

25

For amCharts v4 it will be:

valueAxis.maxPrecision = 0;

Alexey Kosov
  • 3,010
  • 2
  • 23
  • 32
10

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;

Gedalya
  • 899
  • 4
  • 16
  • 28
0

In my code for the valueAxes object I have added integersOnly property true. It is working fine for me.

"valueAxes": [ {
    "gridColor": "#FFFFFF",
    "gridAlpha": 0.2,
    "dashLength": 0,
    "title": "Response Count",
    "autoGridCount": false,
    "gridCount": 5,
    'integersOnly':true
  },
],
Stephen Rauch
  • 47,830
  • 31
  • 106
  • 135
Farida Anjum
  • 529
  • 6
  • 12