Customize tooltip and format the number to 2 decimal places of highcharts

后端 未结 4 1755
南笙
南笙 2021-02-01 14:07

I am using Highcharts graph to display a pie chart. I want to change the tooltip to display the actual data field along with the series name in place of the percent

4条回答
  •  既然无缘
    2021-02-01 14:37

    You can change it so it shows the data value instead by modifying your tooltip pointFormat from pointFormat: '{series.name}: {point.percentage}%', to pointFormat: '{series.name}: {point.y}%',

    You can round the numbers by using the Highcharts.numberFormat() function like so in your formatter:

    formatter: function() {
        return ''+ this.point.name +': '+ Highcharts.numberFormat(this.percentage, 2) +' %';
    }
    

提交回复
热议问题