本文主要是介绍highcharts饼状示例,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
我在模版文件中调用highcharts官网的饼状代码,但是其中 xxx:.1f 显示不出来数据,具体原因不知道是怎么回事,官网上可以,我用就不可以,难道人品问题吗,下面有我的解决办法:
在模版文件调用highcharts.js文件
饼状图:
<div id="alliance_percent" style="width:100%; height: 500px;"></div>
<script type="text/javascript">$(document).ready(function(){
var chart = new Highcharts.Chart({
chart: {
renderTo: 'alliance_percent',
type:'pie',
},
title: {
text: '各渠道金额占百分比'
},
credits:{//右下角的文本
enabled: false,
},
tooltip: {
formatter: function() {
return '<b>'+ this.point.name +'</b>: '+ Highcharts.numberFormat(this.percentage, 2) +'%';
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
depth: 35,
dataLabels: {
color:'black',
enabled: true,
formatter:function(){
return '<b>'+this.point.name+'</b>:'+this.point.percentage.toFixed(2)+"%";
}
},
showInLegend: true
}
},
series: [{
type: 'pie',
name: 'Browser share',
data: [
['苹果',2.56],
['香蕉',5.60],
['梨子',1.60]
]
}]});
});
</script>
例子:
这篇关于highcharts饼状示例的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!