function pSurface::writeXLabels in Visitors 7.2
Same name and namespace in other branches
- 7 pChart/class/pSurface.class.php \pSurface::writeXLabels()
File
- pChart/
class/ pSurface.class.php, line 64
Class
Code
function writeXLabels($Format = "") {
$R = isset($Format["R"]) ? $Format["R"] : $this->pChartObject->FontColorR;
$G = isset($Format["G"]) ? $Format["G"] : $this->pChartObject->FontColorG;
$B = isset($Format["B"]) ? $Format["B"] : $this->pChartObject->FontColorB;
$Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : $this->pChartObject->FontColorA;
$Angle = isset($Format["Angle"]) ? $Format["Angle"] : 0;
$Padding = isset($Format["Padding"]) ? $Format["Padding"] : 5;
$Position = isset($Format["Position"]) ? $Format["Position"] : LABEL_POSITION_TOP;
$Labels = isset($Format["Labels"]) ? $Format["Labels"] : NULL;
$CountOffset = isset($Format["CountOffset"]) ? $Format["CountOffset"] : 0;
if ($Labels != NULL && !is_array($Labels)) {
$Label = $Labels;
$Labels = "";
$Labels[] = $Label;
}
$X0 = $this->pChartObject->GraphAreaX1;
$XSize = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1) / ($this->GridSizeX + 1);
$Settings = array(
"Angle" => $Angle,
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
);
if ($Position == LABEL_POSITION_TOP) {
$YPos = $this->pChartObject->GraphAreaY1 - $Padding;
if ($Angle == 0) {
$Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
}
if ($Angle != 0) {
$Settings["Align"] = TEXT_ALIGN_MIDDLELEFT;
}
}
elseif ($Position == LABEL_POSITION_BOTTOM) {
$YPos = $this->pChartObject->GraphAreaY2 + $Padding;
if ($Angle == 0) {
$Settings["Align"] = TEXT_ALIGN_TOPMIDDLE;
}
if ($Angle != 0) {
$Settings["Align"] = TEXT_ALIGN_MIDDLERIGHT;
}
}
else {
return -1;
}
for ($X = 0; $X <= $this->GridSizeX; $X++) {
$XPos = floor($X0 + $X * $XSize + $XSize / 2);
if ($Labels == NULL || !isset($Labels[$X])) {
$Value = $X + $CountOffset;
}
else {
$Value = $Labels[$X];
}
$this->pChartObject
->drawText($XPos, $YPos, $Value, $Settings);
}
}