首页 新闻 赞助 找找看

highcharts绘制饼图的问题

0
悬赏园豆:5 [已解决问题] 解决于 2014-07-01 10:01

我想再绘制的饼图上显示数值,而不是比例。下面的我的代码

 

 

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]
]
}]
});

康大头的主页 康大头 | 初学一级 | 园豆:25
提问于:2014-06-18 13:33
< >
分享
最佳答案
0

你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也一样加上数量的显示

收获园豆:5
@李城 | 菜鸟二级 |园豆:263 | 2014-06-18 14:55
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册