php - Weird characters when integrated pchart with cakephp
Get the solution ↓↓↓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');
Answer
Solution:
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
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the browser (or proxy) sent a request that this server could not understand.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.