伊谢尔伦2017-04-11 13:21:13
var obj={web:'22',iphone:'30'}; //从后台取出数据,转为object对象
$(function () {
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false
},
title: {
text: ''
},
tooltip: {
formatter: function() {
//tooltip:设置hover时弹出内容,obj[this.point.name] 后台数据
return '<b>'+ this.series.name +'</b>: '+'<b>'+ this.point.name +'</b><br>'+'<b>'+ '登陆次数' +'</b>: '+'<b>'+obj[this.point.name]+'</b>'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
type: 'pie',
name: '用户终端类型',
data: [
['iphone', 26.67],
['web', 73.33]
]
}]
});
});