Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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/

like image 506
Gedalya Avatar asked Dec 05 '13 16:12

Gedalya


People also ask

How do you remove the Y axis from a decimal?

On the Format tab, in the Current Selection group, click Format Selection. Under Axis Options, Click Number, and then in the Category box, select the number format that you want. Tip If the number format you select uses decimal places, you can specify them in the Decimal places box.

How do I change the number format in Amcharts?

Setting output formatNumberFormatter uses format, set in its property numberFormat to turn a numeric value into a formatted string. "numberFormat": "#."

How do I hide the Y axis label in Amcharts?

To "turn off" an axis, all we need to do is to set is disabled property to true . This will remove axis from display, as well as free up space occupied by it for the chart itself.

What is value Axis?

Usually refers to the vertical axis in 2D charts and graphs, which shows the values being measured or compared. Refer to it as the value (y) axis on the first mention. On subsequent mentions, use y-axis.


1 Answers

For amCharts v4 it will be:

valueAxis.maxPrecision = 0;

like image 192
Alexey Kosov Avatar answered Oct 06 '22 16:10

Alexey Kosov