Highcharts - 2个小数位不起作用的工具提示标题格式

时间:2022-02-17 16:36:33

I am trying to configure the tooltip of the so that it displays only 2 decimal places, but the headerformat does not seem to be wokring and it keeps showing the entire decimal places.

我正在尝试配置工具提示,以便它只显示2个小数位,但headerformat似乎没有wokring并且它一直显示整个小数位。

what is going wrong here?

这里出了什么问题?

   {  
       "chart":{  
          "type":"line",
          "height":40,
          "width":40
       },
       "title":{  
          "text":null
       },
       "subtitle":{  
          "text":null
       },
       "xAxis":{  
          "categories":[  

          ]
       },
       "yAxis":{  
          "title":{  
             "enabled":true,
             "text":"Amount (Dollars)",
             "style":{  
                "fontWeight":"normal"
             }
          },
          "plotLines":[  
             {  
                "value":0,
                "width":1,
                "color":"#808080"
             }
          ]
       },
       "options":{  
          "legend":{  
             "enabled":false
          }
       },
       "plotOptions":{  

       },
       "series":[  
          {  
             "name":"Total",
             "data":[  
                {  
                   "name":"Apr'2016",
                   "y":1372406438.2385998
                },
                {  
                   "name":"May'2016",
                   "y":5301389724.7499
                },

            {  
               "name":"Jun'2016",
               "y":549467904.6918
            },
            {  
               "name":"July'2016",
               "y":549040695.1202999
            },
            {  
               "name":"Aug'2016",
               "y":1160837116.1138
            },
            {  
               "name":"Sep'2016",
               "y":22.7612
            }
         ],
         "color":"#008CE6",
         "marker":{  
            "enabled":false
         },
         "id":"series-3"
      },
      {  
         "name":"Toal Timely",
         "data":[  
            {  
               "name":"Apr'2016",
               "y":427101358.1748,
               "month":"Apr"
            },
            {  
               "name":"May'2016",
               "y":5191919648.9571,
               "month":"May"
            },
            {  
               "name":"Jun'2016",
               "y":288691855.262,
               "month":"Jun"
            },
            {  
               "name":"July'2016",
               "y":264281732.18769997,
               "month":"July"
            },
            {  
               "name":"Aug'2016",
               "y":853641906.2942,
               "month":"Aug"
            },
            {  
               "name":"Sep'2016",
               "y":0,
               "month":"Sep"
            }
         ],
         "color":"#4ca977",
         "marker":{  
            "enabled":false
         },
         "id":"series-4"
      },
      {  
         "name":"Total Untimely",
         "data":[  
            {  
               "name":"Apr'2016",
               "y":945305080.0637999,
               "month":"Apr"
            },
            {  
               "name":"May'2016",
               "y":109470075.79279998,
               "month":"May"
            },
            {  
               "name":"Jun'2016",
               "y":260776049.4298,
               "month":"Jun"
            },
            {  
               "name":"July'2016",
               "y":284758962.93259996,
               "month":"July"
            },
            {  
               "name":"Aug'2016",
               "y":307195209.8196,
               "month":"Aug"
            },
            {  
               "name":"Sep'2016",
               "y":22.7612,
               "month":"Sep"
            }
         ],
         "color":"#e54343",
         "marker":{  
            "enabled":false
         },
         "id":"series-5"
      }
   ],
   "tooltip":{  
      "pointFormat":"<b>{point.y}</b>",
      "shared":true
   }
}

1 个解决方案

#1


0  

Add decimals to the point.y value.

将小数添加到point.y值。

"pointFormat": "<b>{point.y:.2f}</b><br>",

Example:

#1


0  

Add decimals to the point.y value.

将小数添加到point.y值。

"pointFormat": "<b>{point.y:.2f}</b><br>",

Example: