此代码实际上不会绘制标题
它使用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错误被抛出,没有控制台调试信息,什么都没有....
我缺少什么?
答案 0 :(得分: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/
答案 1 :(得分: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)
),
),
),
它适用于我。
答案 2 :(得分: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,)
)
)
)
);
&GT;