最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to remove the decimal .00 from the default highcharts configuration? - Stack Overflow

programmeradmin0浏览0评论

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?

You can see the code i'm using here: /

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?

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

Share Improve this question edited Oct 10, 2011 at 22:34 Diego Gomes asked Oct 10, 2011 at 22:13 Diego GomesDiego Gomes 5651 gold badge6 silver badges15 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 7

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

Highcharts.numberFormat(this.y, 0);

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

Using Math.round should solve your problem.

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

http://jsfiddle/CAKQH/20477/

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".

发布评论

评论列表(0)

  1. 暂无评论