function pChart::setLabel in Visitors 7.0
Same name and namespace in other branches
- 8 pchart/pChart.inc \pChart::setLabel()
File
- pchart/
pChart.inc, line 701
Class
Code
function setLabel(&$Data, &$DataDescription, $SerieName, $ValueName, $Caption, $R = 210, $G = 210, $B = 210) {
/* Validate the Data and DataDescription array */
$this
->validateDataDescription("setLabel", $DataDescription);
$this
->validateData("setLabel", $Data);
$C_Label = imagecolorallocate($this->Picture, $R, $G, $B);
$C_Shadow = imagecolorallocate($this->Picture, $R - 30, $G - 30, $B - 30);
$C_TextColor = imagecolorallocate($this->Picture, 0, 0, 0);
$Cp = 0;
$Found = FALSE;
foreach ($Data as $Key => $Value) {
if ($Data[$Key][$DataDescription["Position"]] == $ValueName) {
$NumericalValue = $Data[$Key][$SerieName];
$Found = TRUE;
}
if (!$Found) {
$Cp++;
}
}
$XPos = $this->GArea_X1 + $this->GAreaXOffset + $this->DivisionWidth * $Cp + 2;
$YPos = $this->GArea_Y2 - ($NumericalValue - $this->VMin) * $this->DivisionRatio;
$Position = imageftbbox($this->FontSize, 0, $this->FontName, $Caption);
$TextHeight = $Position[3] - $Position[5];
$TextWidth = $Position[2] - $Position[0];
$TextOffset = floor($TextHeight / 2);
// Shadow
$Poly = array(
$XPos + 1,
$YPos + 1,
$XPos + 9,
$YPos - $TextOffset,
$XPos + 8,
$YPos + $TextOffset + 2,
);
imagefilledpolygon($this->Picture, $Poly, 3, $C_Shadow);
$this
->drawLine($XPos, $YPos + 1, $XPos + 9, $YPos - $TextOffset - 1, $R - 30, $G - 30, $B - 30);
$this
->drawLine($XPos, $YPos + 1, $XPos + 9, $YPos + $TextOffset + 3, $R - 30, $G - 30, $B - 30);
$this
->drawFilledRectangle($XPos + 9, $YPos - $TextOffset, $XPos + 13 + $TextWidth, $YPos + $TextOffset + 2, $R - 30, $G - 30, $B - 30);
// Label background
$Poly = array(
$XPos,
$YPos,
$XPos + 8,
$YPos - $TextOffset - 1,
$XPos + 8,
$YPos + $TextOffset + 1,
);
imagefilledpolygon($this->Picture, $Poly, 3, $C_Label);
$this
->drawLine($XPos - 1, $YPos, $XPos + 8, $YPos - $TextOffset - 2, $R, $G, $B);
$this
->drawLine($XPos - 1, $YPos, $XPos + 8, $YPos + $TextOffset + 2, $R, $G, $B);
$this
->drawFilledRectangle($XPos + 8, $YPos - $TextOffset - 1, $XPos + 12 + $TextWidth, $YPos + $TextOffset + 1, $R, $G, $B);
imagettftext($this->Picture, $this->FontSize, 0, $XPos + 10, $YPos + $TextOffset, $C_TextColor, $this->FontName, $Caption);
}