如何将生成的图形移动到PHP中的所需文件夹?

时间:2014-05-07 11:36:30

标签: php graph

我使用php生成了条形图。我从这个链接下载了类库。 http://www.pchart.net/download.I我正在获取图表。

我想要做的是在创建图像后,它不应该输出到浏览器。而不是我想要将图像保存在特定文件夹中。我该怎么办?提前致谢。这是我的代码

                include("pChart/class/pData.class.php");
                include("pChart/class/pDraw.class.php");
                include("pChart/class/pPie.class.php");
                include("pChart/class/pImage.class.php");
                $MyData = new pData();   
                $MyData->addPoints($val,"ScoreA");  
                $MyData->setSerieDescription("ScoreA","Application A");

                /* Define the absissa serie */
                $MyData->addPoints($keys,"Labels");
                $MyData->setAbscissa("Labels");

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

                /* Draw a solid background */
                $Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
                $myPicture->drawFilledRectangle(0,0,300,300,$Settings);

                /* Overlay with a gradient */
                $Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);
                $myPicture->drawGradientArea(0,0,300,260,DIRECTION_VERTICAL,$Settings);
                $myPicture->drawGradientArea(0,0,300,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>100));

                /* Add a border to the picture */
                $myPicture->drawRectangle(0,0,299,259,array("R"=>0,"G"=>0,"B"=>0));

                /* Write the picture title */ 
                $myPicture->setFontProperties(array("FontName"=>"../fonts/Silkscreen.ttf","FontSize"=>6));
                $myPicture->drawText(10,13,"pPie - Draw 2D pie charts",array("R"=>255,"G"=>255,"B"=>255));

                /* Set the default font properties */ 
                $myPicture->setFontProperties(array("FontName"=>"pChart/fonts/Forgotte.ttf","FontSize"=>10,"R"=>80,"G"=>80,"B"=>80));

                /* Create the pPie object */ 
                $PieChart = new pPie($myPicture,$MyData);

                /* Draw an AA pie chart */ 
                $PieChart->draw3DPie(160,140,array("Radius"=>70,"DrawLabels"=>TRUE,"LabelStacked"=>TRUE,"Border"=>TRUE));

                /* Write the legend box */ 
                $myPicture->setShadow(FALSE);
                $PieChart->drawPieLegend(15,40,array("Alpha"=>20));



                $myPicture->autoOutput("image");

1 个答案:

答案 0 :(得分:0)

尝试使用:

$myPicture->render("image_name.png");

它在1.x中对我有用,不知道2.x - 没用过它。

render()记录在下面链接的pChart wiki中: http://wiki.pchart.net/doc.faq.script.output.html