2010-01-08 33 views
0

我正在使用pChart PHP组件进行图表绘制。发生的事情是,对于某些值,它只是挂起而不绘制图表。这里是我的代码:某些数据值的pChart问题

$DataSet = new pData; 
$DataSet->AddPoint(array(111220, 180496, 103366, 110603, 107354, 100896, 103335, 101180, 102134, 102682, 99938, 96807, 95746, 100057, 95694, 97747, 95919, 94873, 98016, 95627, 98761, 98486, 103944, 106017, 114371, 164686, 104440, 104626, 107983, 119216, 112167, 108124),"YSerie"); 
$DataSet->AddSerie("YSerie"); 
$DataSet->SetAbsciseLabelSerie(); 
$DataSet->SetSerieName("AverageResponses","YSerie"); 

// Initialise the graph 
$Test = new pChart(180, 80); 
$Test->createColorGradientPalette(38, 89, 129, 83, 108, 126, 2); 
$Test->setFontProperties("Fonts/tahoma.ttf", 8); 
$Test->setGraphArea(0, 0, 180, 80); 
$Test->drawGraphArea(0, 0, 0); 
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 0, 0, 0, FALSE); 

$Test->drawFilledLineGraph($DataSet->GetData(),$DataSet->GetDataDescription(),50,TRUE); 
$Test->Stroke(); 

对于这个值,图表不被绘制,它只是挂起。另一方面,对于这个

array(32) { [0]=> int(149871) [1]=> int(176304) [2]=> int(129938) [3]=> int(145667) [4]=> int(129792) [5]=> int(128161) [6]=> int(133420) [7]=> int(137339) [8]=> int(139754) [9]=> int(103679) [10]=> int(101300) [11]=> int(113009) [12]=> int(120305) [13]=> int(113353) [14]=> int(115820) [15]=> int(118757) [16]=> int(110967) [17]=> int(112973) [18]=> int(160397) [19]=> int(291838) [20]=> int(131905) [21]=> int(130459) [22]=> int(130835) [23]=> int(125083) [24]=> int(131659) [25]=> int(133908) [26]=> int(139401) [27]=> int(139670) [28]=> int(144980) [29]=> int(147294) [30]=> int(157745) [31]=> int(163248) } 

得到正确绘制。 任何想法可能是什么问题?

谢谢, 姆拉登纳莱

回答

1

有一个在drawScale()函数中的错误。

在此功能中有以下部分:

while(!$ScaleOk and $counter < 10) 
{ 
$Scale1 = ($this->VMax - $this->VMin)/$Factor; 
$Scale2 = ($this->VMax - $this->VMin)/$Factor/2; 
$Scale4 = ($this->VMax - $this->VMin)/$Factor/4; 

if ($Scale1 > 1 && $Scale1 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale1); $Scale = 1;} 

if ($Scale2 > 1 && $Scale2 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale2); $Scale = 2;} 

if (!$ScaleOk) 

    { 

    if ($Scale2 > 1) { $Factor = $Factor * 10; } 

    if ($Scale2 < 1) { $Factor = $Factor/10; } 

    } 
} 

你图是不够高,然后这个算法保持弹跳秤2之间,一个只是太小了,对方只是太大。

$Test = new pChart(180, 80); 
$Test->setGraphArea(0, 0, 180, 100); 

或通过设置自己的规模:

您可以通过它更高的解决它。

+0

这是有道理的:)你能告诉我如何设置自己的规模调整大小的图形是不是选项? – Mladen 2010-01-10 08:39:17

+0

有一个叫做setFixedScale($ VMin,$ VMax,$ Divisions = 5,$ VXMin = 0,$ VXMin = 0,$ XDivisions = 5)的函数。也许你可以使用那个。 – 2010-01-10 09:14:31

+0

很棒,thx很多 – Mladen 2010-01-11 07:30:07

0

为我工作。

我把后续的命令drawScale前:

$Test->setFixedScale(0, $max_value_from_your_data);