function pPie::writePieLabel in Visitors 7
Same name and namespace in other branches
- 7.2 pChart/class/pPie.class.php \pPie::writePieLabel()
4 calls to pPie::writePieLabel()
- pPie::draw2DPie in pChart/
class/ pPie.class.php - pPie::draw2DRing in pChart/
class/ pPie.class.php - pPie::draw3DPie in pChart/
class/ pPie.class.php - pPie::draw3DRing in pChart/
class/ pPie.class.php
File
- pChart/
class/ pPie.class.php, line 799
Class
Code
function writePieLabel($X, $Y, $Label, $Angle, $Settings, $Stacked, $Xc = 0, $Yc = 0, $Radius = 0, $Reversed = FALSE) {
$LabelOffset = 30;
$FontName = $this->pChartObject->FontName;
$FontSize = $this->pChartObject->FontSize;
if (!$Stacked) {
$Settings["Angle"] = 360 - $Angle;
$Settings["Length"] = 25;
$Settings["Size"] = 8;
$this->pChartObject
->drawArrowLabel($X, $Y, " " . $Label . " ", $Settings);
}
else {
$X2 = cos(deg2rad($Angle - 90)) * 20 + $X;
$Y2 = sin(deg2rad($Angle - 90)) * 20 + $Y;
$TxtPos = $this->pChartObject
->getTextBox($X, $Y, $FontName, $FontSize, 0, $Label);
$Height = $TxtPos[0]["Y"] - $TxtPos[2]["Y"];
$YTop = $Y2 - $Height / 2 - 2;
$YBottom = $Y2 + $Height / 2 + 2;
if ($this->LabelPos != "") {
$Done = FALSE;
foreach ($this->LabelPos as $Key => $Settings) {
if (!$Done) {
if ($Angle <= 90 && ($YTop >= $Settings["YTop"] && $YTop <= $Settings["YBottom"] || $YBottom >= $Settings["YTop"] && $YBottom <= $Settings["YBottom"])) {
$this
->shift(0, 180, -($Height + 2), $Reversed);
$Done = TRUE;
}
if ($Angle > 90 && $Angle <= 180 && ($YTop >= $Settings["YTop"] && $YTop <= $Settings["YBottom"] || $YBottom >= $Settings["YTop"] && $YBottom <= $Settings["YBottom"])) {
$this
->shift(0, 180, -($Height + 2), $Reversed);
$Done = TRUE;
}
if ($Angle > 180 && $Angle <= 270 && ($YTop >= $Settings["YTop"] && $YTop <= $Settings["YBottom"] || $YBottom >= $Settings["YTop"] && $YBottom <= $Settings["YBottom"])) {
$this
->shift(180, 360, $Height + 2, $Reversed);
$Done = TRUE;
}
if ($Angle > 270 && $Angle <= 360 && ($YTop >= $Settings["YTop"] && $YTop <= $Settings["YBottom"] || $YBottom >= $Settings["YTop"] && $YBottom <= $Settings["YBottom"])) {
$this
->shift(180, 360, $Height + 2, $Reversed);
$Done = TRUE;
}
}
}
}
$LabelSettings = array(
"YTop" => $YTop,
"YBottom" => $YBottom,
"Label" => $Label,
"Angle" => $Angle,
"X1" => $X,
"Y1" => $Y,
"X2" => $X2,
"Y2" => $Y2,
);
if ($Angle <= 180) {
$LabelSettings["X3"] = $Xc + $Radius + $LabelOffset;
}
if ($Angle > 180) {
$LabelSettings["X3"] = $Xc - $Radius - $LabelOffset;
}
$this->LabelPos[] = $LabelSettings;
}
}