Skip to content

Instantly share code, notes, and snippets.

@dogmatic69
Created November 25, 2009 14:57
Show Gist options
  • Save dogmatic69/242762 to your computer and use it in GitHub Desktop.
Save dogmatic69/242762 to your computer and use it in GitHub Desktop.
how to use the chart helper
<h2>A test to make sure google is working</h2><?php
echo $this->Chart->test();
?><h2>Same as above but through the helper</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => '60,40',
'labels' => 'Hello,World',
'size' => '250,100',
)
);
?><h2>A simple title</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => array( 60, 40 ),
'labels' => array( 'Hello', 'World' ),
'size' => array( 250, 100 ),
'title' => 'Hello World<br/>Google Chart'
)
);
?><h2>An advanced title</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => array( 60, 40 ),
'labels' => array( 'Hello', 'World' ),
'size' => array( 250, 100 ),
'title' => array(
'text' => 'Hello World<br/>Google Chart',
'size' => 20,
'color' => 'FF0000'
)
)
);
?><h2>An advanced title color only</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => array( 60, 40 ),
'labels' => array( 'Hello', 'World' ),
'size' => array( 250, 100 ),
'title' => array(
'text' => 'Hello World<br/>Google Chart',
'color' => 'FF0000'
)
)
);
?><h2>An advanced title text only</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => array( 60, 40 ),
'labels' => array( 'Hello', 'World' ),
'size' => array( 250, 100 ),
'title' => array(
'text' => 'test'
)
)
);
?><h2>An advanced title size only</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => array( 60, 40 ),
'labels' => array( 'Hello', 'World' ),
'size' => array( 250, 100 ),
'title' => array(
'text' => 'test',
'size' => 30
)
)
);
?><h2>Basic pie with different orientation</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => '60,40',
'labels' => 'Hello,World',
'size' => '250,100',
'orientation' => 90
)
);
?><h2>Basic pie with negative orientation</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => '60,40',
'labels' => 'Hello,World',
'size' => '250,100',
'orientation' => -90
)
);
?><h2>Basic pie with solid fill background</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => '60,40',
'labels' => 'Hello,World',
'size' => '250,100',
'fill' => array(
0 => array(
'position' => 'background',
'type' => 'solid',
'color' => '0000FF',
)
)
)
);
?><h2>Basic pie with chart and background fill</h2><?php
echo $this->Chart->display(
'pie3d',
array(
'data' => '60,40',
'labels' => 'Hello,World',
'size' => '250,100',
'fill' => array(
0 => array(
'position' => 'chart',
'type' => 'solid',
'color' => '0000FF',
),
1 => array(
'position' => 'background',
'type' => 'solid',
'color' => 'FF0000',
)
)
)
);
?><h2>simple line chart</h2><?php
echo $this->Chart->display(
'line',
array(
'data' => array( '60,40,50', array( 10, 20, 70 ) ),
'labels' => 'Hello,World',
'size' => '250,100',
)
);
pr( $this->Chart->errors );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment