highcharts饼状示例

来源:互联网 发布:数据库系统概念中文版 编辑:程序博客网 时间:2024/06/11 06:58

我在模版文件中调用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>

例子:


0 0
原创粉丝点击