Highcharts:用逗号格式化所有数字? [英] Highcharts: Format all numbers with comma?

查看:688
本文介绍了Highcharts:用逗号格式化所有数字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我使用Highcharts,并且想要将图表中任何地方显示的所有数字(工具提示,轴标签...)格式化为逗号分隔的数千个。否则,默认的工具提示和标签很棒,我想保持它们完全一样。



例如,在这个图表中,数字应该是 2,581,326.31 ,但是完全一样。





我该如何做到这一点?

我尝试添加:

  tooltip:{
pointFormat:{point.y:,。0f}
}

但是在工具提示中摆脱了漂亮的圆圈和系列标签 - 我想保留这一点。理想情况下,我希望在整个图表中使用单个选项来设置全局数字格式。

解决方案这可以用 000Sep API )全球选项。

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

请参阅此JSFiddle示例


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 tooltips and labels are great, and i want to keep them exactly the same.

For example, in this chart, the number should be 2,581,326.31 but otherwise exactly the same.

How can I do this?

I tried adding:

    tooltip: {
        pointFormat: "{point.y:,.0f}"
    }

But this got rid of the nice circle and series label in the tooltip - I'd like to keep that. And ideally I'd prefer to use a single option to set global number formatting, across the whole chart.

解决方案

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

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

See this JSFiddle example.

这篇关于Highcharts:用逗号格式化所有数字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆