Diego Gomes
Diego Gomes

Reputation: 565

How to remove the decimal .00 from the default highcharts configuration?

I'm using a integer sequence of values in highcharts, but it's adding .00 after each result. Any tips on how to solve that?

Ex: 353.00 should be 353

You can see the code i'm using here: http://jsfiddle.net/CAKQH/20425/

Upvotes: 0

Views: 10088

Answers (4)

dieb
dieb

Reputation: 339

The second argument for Highcharts.numberFormat specifies how many decimals you want. This should work:

Highcharts.numberFormat(this.y, 0);

http://api.highcharts.com/highcharts#Highcharts.numberFormat()

Upvotes: 7

Bhesh Gurung
Bhesh Gurung

Reputation: 51030

First of all, this is how your data look like -

0, 0, 0, 0, 0, 0, 0, 0, 353.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7.0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
                        ^^^^^                                ^^^

and it does not look like a sequence of integers (only).

But, if it were really a sequence of integers as follows -

0, 0, 0, 0, 0, 0, 0, 0, 353, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

then you could just do -

formatter: function() {
    return Highcharts.dateFormat("%B %e, %Y", this.x) + ': ' + this.y;
}

and Highcharts would never add that ".00".

Upvotes: 0

Allen Liu
Allen Liu

Reputation: 4038

You were only missing one parameter for the .numberFormat() method. Check it out here:

http://jsfiddle.net/CAKQH/20477/

Upvotes: 0

fnky
fnky

Reputation: 705

Using Math.round should solve your problem.

Upvotes: 0

Related Questions