2011-10-21 30 views
0

我正努力在同一图像中生成两个图表。我现在的问题是,当我使用我的方法时,我得到了一些不好的结果。从输出图片中可以看到,第一个图表上有两个垂直轴。我只需要在第二个图表上使用两个垂直轴。使用pchart在一个图像中的两个图表

我认为我的代码不好,或者我的方法不好。如何用pcharts将两个图表生成为相同的图像。只有当我需要两个垂直轴和同一图像上的多个图表时,才会出现此问题。

enter image description here

和我的代码:

<?php 
include("../pchart/class/pData.class.php"); 
include("../pchart/class/pDraw.class.php"); 
include("../pchart/class/pImage.class.php"); 

$MyData = new pData(); 
$MyData->addPoints(array(-4,VOID,VOID,12,8,3),"probe1"); 
$MyData->addPoints(array(3,12,15,8,5,-5),"probe2"); 
$MyData->addPoints(array(2,7,5,18,19,22),"probe3"); 
$MyData->addPoints(array(14,12,10,8,9,12),"probe4"); 
$MyData->addPoints(array(3,4,5,7,6,4),"probe5"); 


$MyData->setAxisName(0,"Temperatures"); 
$MyData->addPoints(array("Jan","Feb","Mar","Apr","May","Jun"),"Labels"); 
$MyData->setSerieDescription("Labels","Months"); 
$MyData->setAbscissa("Labels"); 

$MyData->setSerieOnAxis("probe4", 1); 
$MyData->setAxisPosition(1,AXIS_POSITION_RIGHT); 

$MyData->setSerieDrawable (array("probe4", "probe5"), FALSE); 


$myPicture = new pImage(700,400,$MyData); 
$myPicture->drawRectangle(0,0,699,399,array("R"=>0,"G"=>0,"B"=>0)); 


$myPicture->setFontProperties(array("FontName"=>"../pchart/fonts/Forgotte.ttf","FontSize"=>11)); 
$myPicture->drawText(250,55,"Average temperature",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); 

$myPicture->setGraphArea(60,60,670,190); 
$myPicture->drawFilledRectangle(60,60,670,190,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10)); 
$myPicture->drawScale(array("DrawSubTicks"=>TRUE)); 
$myPicture->drawLineChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO)); 

$MyData->setSerieDrawable (array("probe1", "probe2", "probe3"), FALSE); 
$MyData->setSerieDrawable (array("probe4", "probe5"), TRUE); 


$myPicture->setGraphArea(60,240,670,370); 
$myPicture->drawFilledRectangle(60,240,670,370,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10)); 
$myPicture->drawScale(array("DrawSubTicks"=>TRUE)); 
$myPicture->drawLineChart(array("DisplayValues"=>TRUE,"DisplayColor"=>DISPLAY_AUTO)); 


$myPicture->stroke(); 
?> 

回答

0

这可能是一个更好的办法,但我不知道如何在我的情况下使用它。我不需要饼图,而pImage类只支持尺寸作为第一个参数。

$MyData->addPoints($AAA,"AAA"); 
$MyData->addPoints($abscisse,"Labels"); 

$myPicture = new pImage(X,Y,$MyData); 
..... 
$MyData->setSerieDrawable("AAA",TRUE); 
$myPicture->drawBarChart(); 

$MyData2->addPoints($BBB,"BBB") 
$PieChart = new pPie($myPicture,$MyData2); 
$PieChart->draw3DPie(X,Y,....); 

.... 

$myPicture->stroke(); 
相关问题