Hello everyone,
I need a helper for libchart but at the time of development I've been
stuck in some errors which I really don't know how to compromise.
Here's the example of the Helper class I wrote:
[code]<?php
App::import("Vendor", "libchart", array( "file" =>
"libchart".DS."class".DS."libchart.php" ) );
class ChartHelper extends AppHelper
{
var $helpers = array( "Html" );
function generatePieChart( $title, $fileId, $width = 648, $height
= 432, $data = array() )
{
header("Content-type: image/png");
$chart = new PieChart( $width, $height );
$dataSet = new XYDataSet();
if ( $data != null )
{
foreach( $data as $datum )
$dataSet->addPoint( new Point( $datum["legend"],
$datum["value"] ) );
}
$chart->setDataSet( $dataSet );
$chart->setTitle( $title );
$chart->render( $html->url( "/img/chart/".date( "YmdHis" ).
$fileId.".png" ) );
}
}
?>[/code]
In the controller, I've prepared the data in array with the structure
like this:
[code]Array ( [0] => array( "legend" => "some text", "values" => "some
values" ), [1] => array( "legend" => "some text", "values" => "some
values" ), ... )[/code]
And in the view, I've called it with:
[code]$chart->generatePieChart("testing text", "testingid", 648, 432,
$test);[/code]
I've placed the libchart files in some dirs (just trial-error
approach) like Root/App/Vendors or Root/App/Views/Helpers or Root/App/
WebRoot/ or Root/Vendor but all of them give me errors (the best
minimal error I got was PieChart class not found).
Actually, I'm not too understand how to make a helper class. I've read
the manual and it seems the manual just cover the other helper in cake
for extension functions/uses. So, can someone kindly help me with this
problem? Or maybe one of you have created the helper and kindly shared
to me what it is?
Sorry for my poor English and thanks in advance. Best regards,
Roby.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---