Highcharts: Format all numbers with comma?

后端 未结 3 1562
情深已故
情深已故 2020-12-13 23:05

I\'m using Highcharts and I want to format all numbers showed anywhere in the chart (tooltips, axis labels...) with comma-separated thousands.

Otherwise, the default

相关标签:
3条回答
  • 2020-12-13 23:49

    This way worked with me.

    I configured in yAxis option.

    yAxis: {
      labels: {
        formatter: function() {
            return Highcharts.numberFormat(this.value, 2);
        }
      }
    }
    
    0 讨论(0)
  • 2020-12-14 00:01

    In case you want to show numbers without commas and spaces.

    eg. by default 9800 shows as 9 800.

    If you want 9800 to be shown as 9800

    you can try this in tooltip:

        tooltip: {
         pointFormat: '<span>{point.y:.f}</span>'
       }
    
    0 讨论(0)
  • 2020-12-14 00:04

    This can be set with the thousandSep (API) global option.

    Highcharts.setOptions({
        lang: {
            thousandsSep: ','
        }
    });
    

    See this JSFiddle example.

    0 讨论(0)
提交回复
热议问题