Reputation: 117
When the mouse moves to the series, highcharts displays all the numbers, as shown in this picture:
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.
Upvotes: 3
Views: 7997
Reputation: 11
You can do like this.
formatter: function () {
let perc = this.percentage.toFixed(2)
return `<span>${perc}%</span>`
}
Upvotes: 1
Reputation: 12717
dataLabels controls numbers that show up near the points on the chart itself. That rollover you have in your image is the tooltip. Check out: http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/tooltip/valuedecimals/
tooltip: {
valueDecimals: 2
},
Upvotes: 8