我想通过动态数据在cakephp中创建一个饼图。我已经创建了这个,但它是静态的。我怎样才能让它充满活力。我的代码在这里。
<?php
echo $this->GoogleChart->create ()
->setTitle ( 'Trips Request Graph', array ('size' => 26, 'color' => '000000' ) )
->setType ( 'pie', array ('3d' ) )
->setSize ( 1000, 300 )
->setMargins ( 10, 10, 10, 10, 10 )
->addData ( array (10,10,10) )
->setPieChartLabels ( array ('Riajul','Rafsan','Taukir' ) );
?>
我想在->addData()
和->setPieChartLabels
部分
答案 0 :(得分:1)
试试这个
$arr = array ( 0 => "Riajul", 1 => "Rafsan", 2 => "Taukir"); // your data
$nameString = implode (", ", $arr); // create a comma separated string
echo $this->GoogleChart->create()->setTitle ( 'Trips Request Graph', array ('size' => 26, 'color' => '000000' ) )
->setType ( 'pie', array ('3d' ) )
->setSize ( 1000, 300 )
->setMargins ( 10, 10, 10, 10, 10 )
->addData ( array (10,10,10) )
->setPieChartLabels ( array ($nameString) );
?>