I know this is a bit out there... but gonna ask anyways. I\'m using highcharts jquery script (http://www.highcharts.com/) to generate a pie chart. I am trying to round off the n
There's a numberFormat
function available in the Highcharts API that you can use (see http://www.highcharts.com/ref/#highcharts-object).
Quoted from API doc:
numberFormat (Number number, [Number decimals], [String decimalPoint], [String thousandsSep]) : String
Formats a JavaScript number with grouped thousands, a fixed amount of decimals and an optional decimal point. It is a port of PHP's function with the same name. See PHP number_format for a full explanation of the parameters.
tooltip: {
formatter: function() {
return ''+ this.series.name +''+
this.x +': '+ Highcharts.numberFormat(this.y, 0, ',') +' millions';
}
}, ...
A string with with the input number formatted.
Instead of use formatter
you can set yDecimals
as 2
:
tooltip: {
yDecimals: 2
}
yDecimals: Number
How many decimals to show in each series' y value. This is overridable in each series' tooltip options object. The default is to preserve all decimals.
try
percentageDecimals: 0
in your tooltip
In in the tooltip option in the configuration object use Math.round() in the formatter function.
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage) +' %';
}
},
tooltip: {
valueDecimals: 2
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Math.round(this.percentage*100)/100 +' %';
}
},