【发布时间】:2015-12-29 16:53:24
【问题描述】:
我使用的是 CakePHP 2.x,我需要通过图表显示报告。我看到了 Scott Harwell 的 CakePHP CakePHP GoogleCharts Plugin 这个插件。我一步一步地做所有事情,不知怎的,我的观点一直显得空洞。
DOM 中没有 javascript 输出。
这是我的代码:
我的 bootstrap.php
CakePlugin::load('GoogleCharts');
我的控制器:
$results = $this->Statistique->getIndicateursQuants( $this->request->data );
$this->set( 'results', $results );
$chart = new GoogleCharts();
$chart->type("LineChart");
$chart->options(array('title' => "Etat statistique du nombre de flux"));
$chart->columns(array(
'name' => array(
'type' => 'string',
'label' => 'Name'
),
'nb' => array(
'type' => 'number',
'label' => 'nombre',
)
));
$content_chart =array();
foreach($results as $index => $result){
foreach($result as $cle => $value){
array_push($content_chart,array("name"=>$cle,"nb"=> (int)$value));
}
}
foreach($content_chart as $row){
$chart->addRow(array('name' => $row['name'], 'nb' => $row['nb']));
}
$this->set(compact('chart'));
我的看法:
<div id="chart_div">
<?php $this->GoogleCharts->createJsChart($chart);?>
</div>
我在 GoogleChartsHelper 中有测试器,$scriptOutput 是这样的:
$(document).ready(function(){
options_56823e100db90 = chartOptions = {
"width":400,
"height":300,
"title":"Etat statistique du nombre de flux",
"titleTextStyle":{"color":"red"}
};
js_56823e100dc16 = chartData = new google.visualization.arrayToDataTable([
['Name','nombre'],
['encours',852],
['refuse',11],
['valide',13],
['cloture',91],
['total',967]]);
chart_56823e100dcaf = chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart_56823e100dcaf.draw(js_56823e100dc16, options_56823e100db90);});
但是当我看到源代码时,它并不包含在 DOM 中。
插件:enter image description here
非常感谢。
【问题讨论】:
-
您好,请问您的问题解决了吗?我和你有同样的问题。
标签: javascript jquery cakephp plugins