Automatic Scaling results in infinite loop in lines 464 - 492 of pChart.class.
Proposed solution:
REPLACE (starting at line 462)
elseif ($MaxDivs > 1)
{
while(!$ScaleOk)
{
$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; }
}
}
if ( floor($this->VMax / $Scale / $Factor) != $this->VMax / $Scale / $Factor)
{
$GridID = floor ( $this->VMax / $Scale / $Factor) + 1;
$this->VMax = $GridID * $Scale * $Factor;
$Divisions++;
}
if ( floor($this->VMin / $Scale / $Factor) != $this->VMin / $Scale / $Factor)
{
$GridID = floor( $this->VMin / $Scale / $Factor);
$this->VMin = $GridID * $Scale * $Factor;
$Divisions++;
}
}
BY
elseif ($MaxDivs > 1)
{
$beenup = FALSE;
$beendown = FALSE;
while(!$ScaleOk)
{
$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 && $Scale2 < 10 && $beendown && $beenup) {
if ($MaxDivs < 1) die('Bug in pChart, MaxDivs < 1.');
$Factor = (($this->VMax - $this->VMin) + ($this->VMax - $this->VMin)/$MaxDivs)/2;
if (floor($Factor) < ($this->VMax - $this->VMin) && floor($Factor) >= ($this->VMax - $this->VMin)/$MaxDivs) {
$Factor = floor($Factor);
} else if (ceil($Factor) < ($this->VMax - $this->VMin) && ceil($Factor) >= ($this->VMax - $this->VMin)/$MaxDivs) {
$Factor = ceil($Factor);
}
} else {
if ( $Scale2 > 1 ) { $Factor = $Factor * 10; $beenup = TRUE;}
if ( $Scale2 < 1 ) { $Factor = $Factor / 10; $beendown = TRUE;}
} //Line by Rob
}
}
if ( floor($this->VMax / $Scale / $Factor) != $this->VMax / $Scale / $Factor)
{
$GridID = floor ( $this->VMax / $Scale / $Factor) + 1;
$this->VMax = $GridID * $Scale * $Factor;
$Divisions++;
}
if ( floor($this->VMin / $Scale / $Factor) != $this->VMin / $Scale / $Factor)
{
$GridID = floor( $this->VMin / $Scale / $Factor);
$this->VMin = $GridID * $Scale * $Factor;
$Divisions++;
}
}
NOTE
this might also work (maybe after a bit of altering) for the other two automatic scaling parts in pChart.class. I did not test this.
good work
The solution of https://sourceforge.net/tracker/?func=detail&aid=2126669&group_id=227755&atid=1071632
seems to work better