cakephp piechart by dynamic data

I want to create a pie chart in cakephp by dynamic data.I already create this but it is static. how can i make it dynamic. my code here.

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

I want to set data in ->addData() and ->setPieChartLabels section

Answers


Try this

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

Need Your Help

Error in select statement, with union all in a subquery

sql oracle11g

In Oracle 11g, I came across an error for a query and cannot figure why it is erroring on me. Here is the query:

Recipe for upgrading JBoss 5.x Hibernate to 3.5.x?

hibernate jboss5.x

I'd like to upgrade the Hibernate installation that ships as part of JBoss 5.1.x to Hibernate 3.5.x.