javascript Highcharts y 轴千位分隔符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19810931/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 16:53:28  来源:igfitidea点击:

Highcharts y axis thousands separator

javascripthighchartsformattingnumber-formattingcurrency-formatting

提问by Nuno Nogueira

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

如何向 Highcharts 的 Y 轴添加千位分隔符?

This is what I have:

这就是我所拥有的:

yAxis: [{ // Primary yAxis
                labels: {
                    format: '{point.y:,.0f} ',
                    style: {
                        color: cor1
                    }
                },
              // more code....

This is returning the error:

这是返回错误:

Uncaught TypeError: Cannot read property 'y' of undefined

未捕获的类型错误:无法读取未定义的属性“y”

回答by falsarella

In addition to what @jfrej suggested:

除了@jfrej 的建议

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

因此,由于您正在格式化yAxis,因此{value}应该按预期工作:

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

回答by futantan

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

如果您发现上述解决方案不起作用,请尝试添加以下内容:

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