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

javascript - Highcharts y axis thousands separator - Stack Overflow

programmeradmin7浏览0评论

How to add a thousands separator to the Y Axis of Highcharts?

This is what I have:

yAxis: [{ // Primary yAxis
                labels: {
                    

How to add a thousands separator to the Y Axis of Highcharts?

This is what I have:

yAxis: [{ // Primary yAxis
                labels: {
                    
Share Improve this question edited Feb 16, 2021 at 9:43 asked Nov 6, 2013 at 11:29 user882670user882670 1
  • 8 Try: format: '{value:,.0f} €' – jfrej Commented Nov 6, 2013 at 11:32
Add a ment  | 

3 Answers 3

Reset to default 10

In addition to what @jfrej suggested:

  • If you're directly formatting an axis, use {value} for both yAxis and xAxis:
    • Fiddle for yAxis format
    • Fiddle for xAxis format
  • If you're formatting a point in a tooltip, you may want to use {point.y} and/or {point.x}:
    • Fiddle for tooltip.pointFormat
    • Fiddle for tooltip.pointFormat with valueSuffix extension
  • If you're directly formatting the point label, you may want to use {x} and/or {y}:
    • Fiddle for plotOptions.series.dataLabels, formatting all points
    • Fiddle for series.data.dataLabels, formatting specific point

So, since you're formatting yAxis, {value} should work as expected:

yAxis: {
    labels: {
        format: '{value:,.0f} €'
    }
}

If you find the above solution not working, try to add this:

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

Code to format with ma

var UNDEFINED;

Highcharts.chart(...

...

yAxis: {
       labels: {
              formatter: function () {
                     return Highcharts.numberFormat(this.value, -1, UNDEFINED, ',');
                                     }
               }
       }
发布评论

评论列表(0)

  1. 暂无评论