-1

I have integrated pChart to cakePHP 2, but it's not displaying any graph at all. Just displaying some weird characters when using the autoOutput function of pchart. Any help would be apprciated.

It's displaying like this

?PNG IHDR???? IDATx???{\Uu????A$DD?dfDhD"5???c?9f?y?j3k??3?~?1+???2?8f??8ffffddFHj^????r???????b??~>z????f?6?|?Z??]???/? "?v "r?X"??v ??'X??kG???????1X?a??????v?'N??Oj??|i%RC ,??y3k?????4l?}?y?M?HK#!???????5?6l??e?Z?1?W?$%?z?Qÿ?i??C??P?????dgs???????#^J.????-YY?^?fy@??DG?d ?^???dg???z???(??|?????%.???8????*o?????/F?2??n???d????&M8s??p??^}???x= p????\w?W???{i????????[{??<8?[????E|?9?&q?=4i???f?5?g?z?p???N??F?????Y?og?lf?Do? ?G??[3?u??lKx8??3}?7???oi????$^??~?M?r?-dfR^n?*?!??CB?s??X??§?RTDv??\??Ea!????C?^??????~? !2??=x ?HM5??c??U?]?-0mÇ{????>'9??u??wdg??V?6??????Fn?????v?d?N??Z??4??i?????z??}GByy|?5???f?:$?9?;????][%??#G????7?5??Z=?u????-3f?????v?E=,???DPP? $>?\?8?9sbbx?O?????[{?$???a"-o?e)!;4W??????''??@?8????%K?T ,?Sq)??{??Fr2:?????YX[????% x??AA????{?{X?????#?o?N????|iU?6?/???DXqO_e??}?]??C?[?z?S?:?? f??

This is code i wrote in the controller:

App::import('Vendor', 'PdataClass', array('file' => 'pchart/class' . DS . 'pData.class.php'));
App::import('Vendor', 'PdrawClass', array('file' => 'pchart/class' . DS . 'pDraw.class.php'));
App::import('Vendor', 'PimageClass', array('file' => 'pchart/class' . DS . 'pImage.class.php'));
App::import('Vendor', 'PbubbleClass', array('file' => 'pchart/class' . DS . 'pBubble.class.php'));
$this->autoRender = false;
/* Create and populate the pData object */
$MyData = new pData();  
$MyData->addPoints(array(34,55,15,62,38,42),"Probe1");
$MyData->addPoints(array(5,30,20,9,15,10),"Probe1Weight");
$MyData->addPoints(array(5,10,-5,-1,0,-10),"Probe2");
$MyData->addPoints(array(6,10,14,10,14,6),"Probe2Weight");
$MyData->setSerieDescription("Probe1","This year");
$MyData->setSerieDescription("Probe2","Last year");
$MyData->setAxisName(0,"Current stock");
$MyData->addPoints(array("Apple","Banana","Orange","Lemon","Peach","Strawberry"),"Product");
$MyData->setAbscissa("Product");
$MyData->setAbscissaName("Selected Products");

/* Create the pChart object */
$myPicture = new pImage(700,230,$MyData);

/* Turn of AAliasing */
$myPicture->Antialias = FALSE;

/* Draw the border */
$myPicture->drawRectangle(0,0,699,229,array("R"=>0,"G"=>0,"B"=>0));

$font_name = $fontFolder = APP.'Vendor'.DS.'pchart'.DS.'fonts';

$myPicture->setFontProperties(array("FontName"=>$font_name.DS.'pf_arma_five.ttf',"FontSize"=>6));

/* Define the chart area */
$myPicture->setGraphArea(60,30,650,190);

/* Draw the scale */
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);
$myPicture->drawScale($scaleSettings);

/* Create the Bubble chart object and scale up */
$myPicture->Antialias = TRUE;
$myBubbleChart = new pBubble($myPicture,$MyData);

/* Scale up for the bubble chart */
$bubbleDataSeries   = array("Probe1","Probe2");
$bubbleWeightSeries = array("Probe1Weight","Probe2Weight");
$myBubbleChart->bubbleScale($bubbleDataSeries,$bubbleWeightSeries);

/* Draw the bubble chart */
$myBubbleChart->drawBubbleChart($bubbleDataSeries,$bubbleWeightSeries,array("BorderWidth"=>4,"BorderAlpha"=>50,"Surrounding"=>20));

/* Write the chart legend */
$myPicture->drawLegend(570,13,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));

$myPicture->autoOutput(APP.'Vendor'.DS.'pchart'.DS.'pictures'.DS.'example.jpeg');
Florent
  • 12,310
  • 10
  • 49
  • 58
saurabh kackar
  • 209
  • 1
  • 2
  • 9
  • 2
    Can you add some details? Like what kind of data you're trying to display and the code you're trying to do it with. – Khantahr Oct 17 '12 at 19:34
  • It showing something like this this when trying to display the graph on cakePHP 2 ?PNG IHDR???? IDATx???{\Uu????A$DD?dfDhD"5???c?9f?y?j3k??3?~?1+???2?8f??8ffffddFHj^????r???????b??~>z????f?6?|?Z??]???/? "?v "r?X"??v ??'X??kG???????1X?a??????v?'N??Oj??|i%RC ,??y3k?????4l?}?y?M?HK#!???????5?6l`??e?Z?1?W?$%?z?Qÿ?i??C??P?????dgs???????#^J.????-YY?^?fy@??DG?d ?^???dg???z???(??|?????%.???8????*o?????/F?2??`n???d????&M8s??p??^}???x= p????\w?W???{i????????[{??<8?[????E|?9?&q?=4i???f?5?g?z?p???N??F?????Y?og?lf?Do? ?G?? like this – saurabh kackar Oct 18 '12 at 12:55
  • Look at the beginning of your data: `PNG`. You're displaying an PNG image. Try to add `Content-Type: image/png` header... – Florent Oct 18 '12 at 13:25
  • Already added the script you are saying – saurabh kackar Oct 18 '12 at 13:27

1 Answers1

0

found the solution for where i found the pchart is now working with CakePHP 2.0 version. I just a line at the end of the code: exit;

Thanks

saurabh kackar
  • 209
  • 1
  • 2
  • 9