3

When the mouse moves to the series, highcharts displays all the numbers, as shown in this picture:

enter image description here

I want to make the float numbers all have 2 digits after dot point. I searched online, and came up sth like:

    plotOptions: {
        series: {
            dataLabels: {
                formatter: function() {
                    return '<b>' + this.point.name + '</b>: ' + this.percentage.toFixed(2) + ' %';
                }
            }
        }
    }

But it does not work.

4

2 回答 2

8

dataLabels 控制显示在图表本身点附近的数字。您在图像中的翻转是工具提示。查看:http: //jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/tooltip/valuedecimals/

    tooltip: {
        valueDecimals: 2
    },
于 2013-07-24T16:28:57.923 回答
1

你可以这样做。

formatter: function () {
    let perc = this.percentage.toFixed(2)
    return `<span>${perc}%</span>`
}
于 2016-12-14T01:41:12.930 回答