|
|
|
@ -586,7 +586,6 @@ |
|
|
|
|
/* Horizontal Axis */ |
|
|
|
|
$XPos = $this->GArea_X1 + $this->GAreaXOffset; |
|
|
|
|
$ID = 1; $YMax = NULL; |
|
|
|
|
$maxTextHeight = 0; |
|
|
|
|
foreach ( $Data as $Key => $Values ) |
|
|
|
|
{ |
|
|
|
|
if ( $ID % $SkipLabels == 0 ) |
|
|
|
@ -608,10 +607,6 @@ |
|
|
|
|
$TextWidth = abs($Position[2])+abs($Position[0]); |
|
|
|
|
$TextHeight = abs($Position[1])+abs($Position[3]); |
|
|
|
|
|
|
|
|
|
// Save max text height |
|
|
|
|
if ($maxTextHeight < $TextHeight) { |
|
|
|
|
$maxTextHeight = $TextHeight; |
|
|
|
|
} |
|
|
|
|
if ( $Angle == 0 ) |
|
|
|
|
{ |
|
|
|
|
$YPos = $this->GArea_Y2+18; |
|
|
|
@ -619,13 +614,51 @@ |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
$YPos = $this->GArea_Y2+10; |
|
|
|
|
// If rotation is top down, then add TextHeight; |
|
|
|
|
$YPos = (sin($Angle) < 0) ? $YPos + $TextHeight : $YPos; |
|
|
|
|
if ( $Angle <= 90 ) |
|
|
|
|
imagettftext($this->Picture,$this->FontSize,$Angle,floor($XPos)-$TextWidth+5,$YPos,$C_TextColor,$this->FontName,$Value); |
|
|
|
|
else |
|
|
|
|
imagettftext($this->Picture,$this->FontSize,$Angle,floor($XPos)+$TextWidth+5,$YPos,$C_TextColor,$this->FontName,$Value); |
|
|
|
|
// Will change XY positions to show the right label position |
|
|
|
|
// To detect side of cartesian plane XY where angles ends |
|
|
|
|
// e.g 60 degree is in Quadrant I, 120 degree is Quadrant II |
|
|
|
|
$isYpositive = sin(deg2rad($Angle)) >= 0; |
|
|
|
|
$isXpositive = cos(deg2rad($Angle)) >= 0; |
|
|
|
|
$YPos = $this->GArea_Y2 + 10; |
|
|
|
|
if ($isYpositive && $isXpositive) { |
|
|
|
|
// For Quadrant I |
|
|
|
|
$YPos += $TextHeight; |
|
|
|
|
$XPos -= $TextWidth; |
|
|
|
|
} elseif ($isYpositive && !$isXpositive) { |
|
|
|
|
// For Quadrant II |
|
|
|
|
$YPos += $TextHeight; |
|
|
|
|
$XPos += $TextWidth; |
|
|
|
|
} elseif (!$isYpositive && !$isXpositive) { |
|
|
|
|
// For Quadrant III |
|
|
|
|
// Nothing to do |
|
|
|
|
} else { |
|
|
|
|
// For Quadrant IV |
|
|
|
|
// Nothing to do |
|
|
|
|
} |
|
|
|
|
imagettftext( |
|
|
|
|
$this->Picture, |
|
|
|
|
$this->FontSize, |
|
|
|
|
$Angle, |
|
|
|
|
$XPos, |
|
|
|
|
$YPos, |
|
|
|
|
$C_TextColor, |
|
|
|
|
$this->FontName, |
|
|
|
|
$Value |
|
|
|
|
); |
|
|
|
|
// post update XY position |
|
|
|
|
if ($isYpositive && $isXpositive) { |
|
|
|
|
// For Quadrant I |
|
|
|
|
$XPos += $TextWidth; |
|
|
|
|
} elseif ($isYpositive && !$isXpositive) { |
|
|
|
|
// For Quadrant II |
|
|
|
|
$XPos -= $TextWidth; |
|
|
|
|
} elseif (!$isYpositive && !$isXpositive) { |
|
|
|
|
// For Quadrant III |
|
|
|
|
$YPos += $TextHeight; |
|
|
|
|
} else { |
|
|
|
|
// For Quadrant IV |
|
|
|
|
$YPos += $TextHeight; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if ( $YMax < $YPos || $YMax == NULL ) { $YMax = $YPos; } |
|
|
|
|
} |
|
|
|
@ -635,12 +668,21 @@ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Write the X Axis caption if set */ |
|
|
|
|
if ( isset($DataDescription["Axis"]["X"]) ) |
|
|
|
|
{ |
|
|
|
|
$Position = imageftbbox($this->FontSize,90,$this->FontName,$DataDescription["Axis"]["X"]); |
|
|
|
|
$TextWidth = abs($Position[2])+abs($Position[0]); |
|
|
|
|
$TextLeft = (($this->GArea_X2 - $this->GArea_X1) / 2) + $this->GArea_X1 + ($TextWidth/2); |
|
|
|
|
imagettftext($this->Picture,$this->FontSize,0,$TextLeft,$YMax+$this->FontSize+5+$maxTextHeight,$C_TextColor,$this->FontName,$DataDescription["Axis"]["X"]); |
|
|
|
|
if (isset($DataDescription["Axis"]["X"])) |
|
|
|
|
{ |
|
|
|
|
$Position = imageftbbox($this->FontSize, 0, $this->FontName, $DataDescription["Axis"]["X"]); |
|
|
|
|
$TextWidth = abs($Position[2]) + abs($Position[0]); |
|
|
|
|
$TextLeft = (($this->GArea_X2 + $this->GArea_X1) / 2) - ($TextWidth/2); |
|
|
|
|
imagettftext( |
|
|
|
|
$this->Picture, |
|
|
|
|
$this->FontSize, |
|
|
|
|
0, |
|
|
|
|
$TextLeft, |
|
|
|
|
$YMax+$this->FontSize+5, |
|
|
|
|
$C_TextColor, |
|
|
|
|
$this->FontName, |
|
|
|
|
$DataDescription["Axis"]["X"] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|