高图,我不画饼


Highchart and yii not drawing a pie

这段代码实际上除了标题什么也没画

它使用Highcharts就像一个yii扩展

<?php $this->Widget('ext.highcharts.HighchartsWidget', array(
   'options'=>array(
        'title' => array('text' => 'Grafico a torta'),
        'chart' => array('renderTo' =>'charts'),
        'credits' => array('enabled' => false),
        'series' => array (
            'type' => 'pie',
            'name' => 'name of serie',
            'data' => array (
                array('Firefox', 44.2),
                array('IE7', 26.6),
                array('IE6', 20),
                array('Chrome', 3.1),
                array('Other', 5.4)
            ),
        ),
   )
));
?>

它创建这个javascript

jQuery(window).on('load',function() {
var chart = new Highcharts.Chart(
    {'chart':{'renderTo':'charts'},
     'exporting':{'enabled':true},
     'title':{'text':'Grafico a torta'},
     'credits':{'enabled':false},
     'series':{
           'type':'pie',
           'name':'name of serie',
           'data':[
                ['Firefox',44.2000000000000028],
                ['IE7',26.6000000000000014],
                ['IE6',20],
                ['Chrome',3.1000000000000001],
                ['Other',5.4000000000000004]
           ]}});
});

我不明白怎么了....没有抛出js错误,没有控制台调试信息,没有....

我错过了什么

查看你的目录:

series:**[**{
           type:'pie',
           name:'name of serie',
           data:[
                ['Firefox',44.2000000000000028],
                ['IE7',26.6000000000000014],
                ['IE6',20],
                ['Chrome',3.1000000000000001],
                ['Other',5.4000000000000004]
           ]}**]**
    });

您在系列中缺少[]。检查一下:http://jsfiddle.net/tqVF8/9/

再次使用数组

section =>
   'series' => array (
        array (
          'type' => 'pie',
          'name' => 'Browser share',
          'data' => array (
           array('Firefox', 44.2),
           array('IE7', 26.6),
           array('IE6', 20),
           array('Chrome', 3.1),
           array('Other', 5.4)
        ),
    ),
),        

在此数据中为事件数计数数组。

<?php
$this->Widget('application.extensions.highcharts.HighchartsWidget',
array('options'=>array( 'title'=>array('text'=>'User Distribution'),
                        'tooltip'=>array('formatter'=> 'js:function() { 
        return "<b>"+this.point.name+"</b>: "+Math.round(this.percentage)+"%"
          }'),
'credits' => array('enabled' => true),
'exporting' => array('enabled' => true),
'plotOptions'=>array('pie'=> array('allowPointSelect'=>true,'cursor'=>'pointer',
                                                                                            'dataLabels'=>array('enabled'=>true),
                                                                                            'showInLegend'=>true)
                                                                        ),
                                                    'series' =>                           array(array('type'=>'pie',                                                             'name'=>'User Distrubution',
                                                                            'data' => $data,)
                                                                    )
                                                    )
                                    )
                        );

?>