Formatting Tooltip of Values >1000

2019-07-30 21:55发布

I am using an ohlc highstock chart in my project. I have values in 4-5 digits. For example

Open     : 2717.35
High     : 2719.5
Low      : 2709.18
Close    : 2712.97
SMA(50)  : 2677.4904
SMA(200) : 2627.7230
Volume   : 3368690000

In the tooltip of the chart, I want these values like this (added comma)

Open     : 2,717.35
High     : 2,719.5
Low      : 2,709.18
Close    : 2,712.97
SMA(50)  : 2,677.4904
SMA(200) : 2,627.7230
Volume   : 3,368,690,000

But in the case of 4 digit values, tooltip looks like this

enter image description here

There's a space in the 4-digit values. Is there any way to format it so that it should come like I mentioned above? I also have some SMA series and a volume series in the chart. Is there any way to use that to format the values?

My highstock options

{
          colors:Global.colors,
          rangeSelector: {
            selected: 1
          },
          title: {
            text: ''
          },
          xAxis: {
            crosshair: true
          },
          yAxis: [
            {
              labels: {
                align: 'right',
                x: -3
              },
              height: '60%',
              lineWidth: 2,
              resize: {
                enabled: true
              },
            }, {
              labels: {
                align: 'right',
                x: -3
              },
              top: '65%',
              height: '35%',
              offset: 0,
              lineWidth: 2
            }],
            tooltip: {
              split: true,
              distance: 50,
              padding: 2,
            },
          credits: {
            enabled: false
          },
          legend: {
            enabled: false
          },
          plotOptions: {
            series: {
              marker: {
                enabled: false
              }
            },
          }
        }

Note: I am getting data from the server so I am setting data in the series after the completion of the http call.

1条回答
叛逆
2楼-- · 2019-07-30 22:44

You need to set the thousands seperator. Like this:

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

Working JSFiddle example: https://jsfiddle.net/ewolden/72xr9qvL/5

查看更多
登录 后发表回答