【问题标题】:How to add thousands separator in highcharts tool tip text box如何在 highcharts 工具提示文本框中添加千位分隔符
【发布时间】:2023-04-07 07:10:01
【问题描述】:

我正在尝试在 highcharts 工具提示文本框中格式化数字。这个数字看起来像这样#######.## 我想要#,###,###.## 我该怎么做?我现在的代码是:

PointFormat = "<b>{series.name}: {point.y:.2f}</b>"

我试过了:

PointFormat = "<b>{series.name}: {point.y:.2n}</b>"

将其格式化为数字,但这不起作用。我的数字格式不太好。

【问题讨论】:

标签: c# highcharts number-formatting


【解决方案1】:

在语言中使用千位分隔符

$(function () {
Highcharts.setOptions({

    lang: {
      decimalPoint: '.',
      thousandsSep: ','
    }
});

并在工具提示格式化程序中使用,如

  {point.y:,.2f}

【讨论】:

  • 我尝试了以下方法,但它没有做任何事情。格式仍然保留... .SetOptions(new GlobalOptions{ Lang = new DotNet.Highcharts.Helpers.Lang { ThousandsSep = ","} })
  • 实际上,我收回了它,我只需要去删除 :.2f 就可以了! .2f 正在撤消 ThousandsSep,谢谢!
【解决方案2】:

如果你使用

plotOptions:{
dataLabels:{
format: {point.y: ,.1f}
}
}

这样它也适用于数据标签。

@Nishith 提到的工具提示也是如此

【讨论】:

    猜你喜欢
    • 2020-08-20
    • 2021-04-13
    • 2013-11-17
    • 1970-01-01
    • 1970-01-01
    • 2016-04-06
    • 2021-11-17
    • 2015-07-12
    相关资源
    最近更新 更多