2013-04-30 25 views
0

這段代碼居然不畫什麼,但標題Highchart和警予不畫大餅

它使用Highcharts像一個警予延長

<?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錯誤被拋出,而不是控制檯調試信息,什麼都沒有....

我失蹤了什麼?

回答

4

檢查意甲:

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/

+2

這將意味着你需要另一個陣列串聯部 – acorncom 2013-04-30 19:36:17

0

使用數組一次串聯

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) 
     ), 
    ), 
),   

它與我。

0

這個數據是事件數的數組數。

<?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,) 
                    ) 
                ) 
            ) 
         ); 

?>