动态数据的cakephp饼图
cakephp piechart by dynamic data
我想通过动态在 cakephp 中创建一个饼图 data.I 已经创建了,但它是静态的。我怎样才能使它动态。我的代码在这里。
<?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
部分设置数据
试试这个
$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) );
?>
我想通过动态在 cakephp 中创建一个饼图 data.I 已经创建了,但它是静态的。我怎样才能使它动态。我的代码在这里。
<?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
部分设置数据
试试这个
$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) );
?>