Formatting Tooltip of Values >1000

∥☆過路亽.° 提交于 2019-12-11 08:03:20

问题


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

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:


You need to set the thousands seperator. Like this:

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

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



来源:https://stackoverflow.com/questions/51153160/formatting-tooltip-of-values-1000

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!