我想再绘制的饼图上显示数值,而不是比例。下面的我的代码
chart1 = new Highcharts.Chart({
chart: {
renderTo: 'container1',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: '设备状态'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage}%</b>',
percentageDecimals: 1
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
},
}
},
series: [{
type: 'pie',
name: '所占比率',
data: [
['非法运营', b1_ratio],
{
name:'离线',
y:b2_ratio,
selected:true,
sliced: true,
}
,
['运营', b3_ratio]
]
}]
});
你tooltip中得format和pie中得format都只是指定了显示百分比,没有指定要显示数量
tooltip: { formatter: function() { return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage, 2) +'% ('+ Highcharts.numberFormat(this.y, 0, ',') +')'; }
同理
pie属性的dataLabels中的format也一样加上数量的显示