function pScatter::drawScatterThresholdArea in Visitors 7.2
Same name and namespace in other branches
- 7 pChart/class/pScatter.class.php \pScatter::drawScatterThresholdArea()
File
- pChart/
class/ pScatter.class.php, line 1056
Class
Code
function drawScatterThresholdArea($Value1, $Value2, $Format = "") {
$AxisID = isset($Format["AxisID"]) ? $Format["AxisID"] : 0;
$R = isset($Format["R"]) ? $Format["R"] : 255;
$G = isset($Format["G"]) ? $Format["G"] : 0;
$B = isset($Format["B"]) ? $Format["B"] : 0;
$Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 20;
$Border = isset($Format["Border"]) ? $Format["Border"] : TRUE;
$BorderR = isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
$BorderG = isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
$BorderB = isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
$BorderAlpha = isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha + 20;
$BorderTicks = isset($Format["BorderTicks"]) ? $Format["BorderTicks"] : 2;
$AreaName = isset($Format["AreaName"]) ? $Format["AreaName"] : "La ouate de phoque";
//NULL;
$NameAngle = isset($Format["NameAngle"]) ? $Format["NameAngle"] : ZONE_NAME_ANGLE_AUTO;
$NameR = isset($Format["NameR"]) ? $Format["NameR"] : 255;
$NameG = isset($Format["NameG"]) ? $Format["NameG"] : 255;
$NameB = isset($Format["NameB"]) ? $Format["NameB"] : 255;
$NameAlpha = isset($Format["NameAlpha"]) ? $Format["NameAlpha"] : 100;
$DisableShadowOnArea = isset($Format["DisableShadowOnArea"]) ? $Format["DisableShadowOnArea"] : TRUE;
if ($Value1 > $Value2) {
list($Value1, $Value2) = array(
$Value2,
$Value1,
);
}
$RestoreShadow = $this->pChartObject->Shadow;
if ($DisableShadowOnArea && $this->pChartObject->Shadow) {
$this->pChartObject->Shadow = FALSE;
}
if ($BorderAlpha > 100) {
$BorderAlpha = 100;
}
$Data = $this->pDataObject
->getData();
if (!isset($Data["Axis"][$AxisID])) {
return -1;
}
if ($Data["Axis"][$AxisID]["Identity"] == AXIS_X) {
$Y1 = $this->pChartObject->GraphAreaY1 + $Data["Axis"][$AxisID]["Margin"];
$Y2 = $this->pChartObject->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"];
$X1 = $this
->getPosArray($Value1, $AxisID);
$X2 = $this
->getPosArray($Value2, $AxisID);
if ($X1 <= $this->pChartObject->GraphAreaX1) {
$X1 = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"];
}
if ($X2 >= $this->pChartObject->GraphAreaX2) {
$X2 = $this->pChartObject->GraphAreaX2 - $Data["Axis"][$AxisID]["Margin"];
}
$this->pChartObject
->drawFilledRectangle($X1, $Y1, $X2, $Y2, array(
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
));
if ($Border) {
$this->pChartObject
->drawLine($X1, $Y1, $X1, $Y2, array(
"R" => $BorderR,
"G" => $BorderG,
"B" => $BorderB,
"Alpha" => $BorderAlpha,
"Ticks" => $BorderTicks,
));
$this->pChartObject
->drawLine($X2, $Y1, $X2, $Y2, array(
"R" => $BorderR,
"G" => $BorderG,
"B" => $BorderB,
"Alpha" => $BorderAlpha,
"Ticks" => $BorderTicks,
));
}
if ($AreaName != NULL) {
$XPos = ($X2 - $X1) / 2 + $X1;
$YPos = ($Y2 - $Y1) / 2 + $Y1;
if ($NameAngle == ZONE_NAME_ANGLE_AUTO) {
$TxtPos = $this->pChartObject
->getTextBox($XPos, $YPos, $this->pChartObject->FontName, $this->pChartObject->FontSize, 0, $AreaName);
$TxtWidth = $TxtPos[1]["X"] - $TxtPos[0]["X"];
if (abs($X2 - $X1) > $TxtWidth) {
$NameAngle = 0;
}
else {
$NameAngle = 90;
}
}
$this->pChartObject->Shadow = $RestoreShadow;
$this->pChartObject
->drawText($XPos, $YPos, $AreaName, array(
"R" => $NameR,
"G" => $NameG,
"B" => $NameB,
"Alpha" => $NameAlpha,
"Angle" => $NameAngle,
"Align" => TEXT_ALIGN_MIDDLEMIDDLE,
));
if ($DisableShadowOnArea) {
$this->pChartObject->Shadow = FALSE;
}
}
$this->pChartObject->Shadow = $RestoreShadow;
return array(
"X1" => $X1,
"X2" => $X2,
);
}
elseif ($Data["Axis"][$AxisID]["Identity"] == AXIS_Y) {
$X1 = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"];
$X2 = $this->pChartObject->GraphAreaX2 - $Data["Axis"][$AxisID]["Margin"];
$Y1 = $this
->getPosArray($Value1, $AxisID);
$Y2 = $this
->getPosArray($Value2, $AxisID);
if ($Y1 >= $this->pChartObject->GraphAreaY2) {
$Y1 = $this->pChartObject->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"];
}
if ($Y2 <= $this->pChartObject->GraphAreaY1) {
$Y2 = $this->pChartObject->GraphAreaY1 + $Data["Axis"][$AxisID]["Margin"];
}
$this->pChartObject
->drawFilledRectangle($X1, $Y1, $X2, $Y2, array(
"R" => $R,
"G" => $G,
"B" => $B,
"Alpha" => $Alpha,
));
if ($Border) {
$this->pChartObject
->drawLine($X1, $Y1, $X2, $Y1, array(
"R" => $BorderR,
"G" => $BorderG,
"B" => $BorderB,
"Alpha" => $BorderAlpha,
"Ticks" => $BorderTicks,
));
$this->pChartObject
->drawLine($X1, $Y2, $X2, $Y2, array(
"R" => $BorderR,
"G" => $BorderG,
"B" => $BorderB,
"Alpha" => $BorderAlpha,
"Ticks" => $BorderTicks,
));
}
if ($AreaName != NULL) {
$XPos = ($X2 - $X1) / 2 + $X1;
$YPos = ($Y2 - $Y1) / 2 + $Y1;
$this->pChartObject->Shadow = $RestoreShadow;
$this->pChartObject
->drawText($YPos, $XPos, $AreaName, array(
"R" => $NameR,
"G" => $NameG,
"B" => $NameB,
"Alpha" => $NameAlpha,
"Angle" => 0,
"Align" => TEXT_ALIGN_MIDDLEMIDDLE,
));
if ($DisableShadowOnArea) {
$this->Shadow = FALSE;
}
}
$this->pChartObject->Shadow = $RestoreShadow;
return array(
"Y1" => $Y1,
"Y2" => $Y2,
);
}
}