dongqun5769 2012-04-24 06:21
浏览 110
已采纳

pChart输出图像的问题。 怎么了?

I'm having an issue displaying the 3DPie example pChart in my php page, no matter what the output (Stroke(),autoOutput(),render()) it doesn't render to the browser, but the examples work in the examples folder.

My question is: why won't it render to browser? How do I fix it? (its not the includes, they worked for the basic syntax tutorial)

include("code libraries/pChart2.1.3/class/pDraw.class.php");
include("code libraries/pChart2.1.3/class/pImage.class.php");
include("code libraries/pChart2.1.3/class/pData.class.php");

 /* Create and populate the pData object */
 $MyData = new pData();   
 $MyData->addPoints(array(50,2,3,4,7,10,25,48,41,10),"ScoreA");  
 $MyData->setSerieDescription("ScoreA","Application A");

 /* Define the absissa serie */
 $MyData->addPoints(array("A0","B1","C2","D3","E4","F5","G6","H7","I8","J9"),"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"=>"code libraries/pChart2.1.3/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"=>"code libraries/pChart2.1.3/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));

 /* Render the picture (choose the best way) */
 $myPicture->autoOutput("vgraph.png");

展开全部

  • 写回答

1条回答 默认 最新

  • dqcwl02022 2012-04-24 08:24
    关注

    Possible Errors

    A. You did not include pPie.class.php in your script

    B. Possible wrong path

    C. Possible Wrong Font location

    Try

    require("lib/pchart/class/pData.class.php");
    require("lib/pchart/class/pDraw.class.php");
    require("lib/pchart/class/pImage.class.php");
    require("lib/pchart/class/pPie.class.php");
    
    
    $font1 = "lib/pchart/fonts/pf_arma_five.ttf" ;
    $font2 = "lib/pchart/fonts/pf_arma_five.ttf" ;
    
     $MyData = new pData();   
     $MyData->addPoints(array(50,2,3,4,7,10,25,48,41,10),"ScoreA");  
     $MyData->setSerieDescription("ScoreA","Application A");
    
     /* Define the absissa serie */
     $MyData->addPoints(array("A0","B1","C2","D3","E4","F5","G6","H7","I8","J9"),"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"=>$font1,"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"=>$font2,"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));
    
     /* Render the picture (choose the best way) */
     $myPicture->autoOutput("vgraph.png");
    

    Result

    Final Output

    展开全部

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部