当与cakephp集成pchart时奇怪的字符

时间:2012-10-17 19:30:30

标签: php cakephp pchart

我已经将pChart集成到cakePHP 2中,但它根本没有显示任何图形。在使用pchart的autoOutput函数时只显示一些奇怪的字符。任何帮助都会得到解决。

它显示如下

  

?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'QY?我48 C&Delta; P ????? DGS ???????#道^ J。? -YY?^?fy @ ?? DG?d?^ ??? dg ???????????????????????????????????????????????? ???? / F 2&pi; 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?????伏d N 10ż?? 4 ??我?????ž??} GByy | 5 ??? F:????$? ?9;?????] [%??#ģ???? 7 5 ?? Z =ü???? - 3F ????? v E =,??? DPP ?$&gt;?\?8?9sbbx?O ????? [{?$ ??? a“-o?e )!; 4W ??????''?? ?? 8%K?T,?Sq)?? {ΔFn2:YX [????%x ?? AA ????? {?{X ?????# α,αñ???? |????6 IU / ??? DXqO_e ??}] ?? C?[?z?S?:?? f??

这是我在控制器中写的代码:

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

1 个答案:

答案 0 :(得分:0)

找到解决方案,我发现pchart现在正在使用CakePHP 2.0版本。 我只是代码末尾的一行: 的 exit;

由于