我给那个值Highcharts饼图:
series:[
{
type:'pie',
name:'Ratio',
data:[
['A', 42.6],
{
name:'B',
y:14.2,
sliced:true,
selected:true
}
]
}
]
但是它显示了它这样的饼图:
A -> 75.00000000000001 %
B-> 25 %
你可以在怎么样图表值Highcharts格式化工具提示?
![](https://www.manongdao.com/static/images/pcload.jpg)
我们确实有提示格式化选项来显示值作为数字而不是百分比
http://api.highcharts.com/highstock#tooltip.formatter
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ this.point.y ;
}
},
this.point.y会做的伎俩(现在你有this.percentage在那个地方)
plotOptions.pie.dataLabels.formatter
是,可以让你格式化标签的功能。 在这种情况下,我回到this.percentage.toFixed(2)
将在2位小数修剪你的电话号码。 演示在此的jsfiddle
plotOptions: {
pie: {
dataLabels: {
formatter: function() {
return '<b>' + this.point.name + '</b>: ' + this.percentage.toFixed(2) + ' %';
}
}
}
},
你可以只格式化这样的下面。
tooltip: {
pointFormat: "Value: {point.y:.2f}"
}
约Highcharts格式文档
tooltip: {
pointFormat: "Value: {point.y:.2f}"
}
这不是在格式化的值。
var data = [{
name: 'Population',
data: [],
dataLabels: {
enabled: true,
rotation: -90,
color: '#FFFFFF',
align: 'right',
x: 4,
y: 10,
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif',
textShadow: '0 0 3px black'
}, formatter: function() {
return Highcharts.numberFormat(this.y, 2, '.');
}
}
}];
的值的formart可以是在数据中的变化dataLables。
tooltip: {
pointFormat: "Percentage: {point.percentage:.2f}"
}
这会给你的百分比值