function pDraw::drawXThresholdArea
Search API
5.x pDraw.class.php | pDraw::drawXThresholdArea($Value1, $Value2, $Format = "") |
File
- inc/
pchart/ pchart/ class/ pDraw.class.php, line 2749
Class
Code
function drawXThresholdArea($Value1, $Value2, $Format = "")
{
$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"] : 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;
$RestoreShadow = $this->Shadow;
if ($DisableShadowOnArea && $this->Shadow) {
$this->Shadow = FALSE;
}
if ($BorderAlpha > 100) {
$BorderAlpha = 100;
}
$Data = $this->DataSet->getData();
$XScale = $this->scaleGetXSettings();
$AbscissaMargin = $this->getAbscissaMargin($Data);
if ($Data ["Orientation"] == SCALE_POS_LEFTRIGHT)
{
$XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale [0] * 2) / $XScale [1];
$XPos1 = $this->GraphAreaX1 + $XScale [0] + $XStep * $Value1;
$XPos2 = $this->GraphAreaX1 + $XScale [0] + $XStep * $Value2;
$YPos1 = $this->GraphAreaY1 + $Data ["YMargin"];
$YPos2 = $this->GraphAreaY2 - $Data ["YMargin"];
if ($XPos1 < $this->GraphAreaX1 + $XScale [0]) {
$XPos1 = $this->GraphAreaX1 + $XScale [0];
}
if ($XPos1 > $this->GraphAreaX2 - $XScale [0]) {
$XPos1 = $this->GraphAreaX2 - $XScale [0];
}
if ($XPos2 < $this->GraphAreaX1 + $XScale [0]) {
$XPos2 = $this->GraphAreaX1 + $XScale [0];
}
if ($XPos2 > $this->GraphAreaX2 - $XScale [0]) {
$XPos2 = $this->GraphAreaX2 - $XScale [0];
}
$this->drawFilledRectangle($XPos1, $YPos1, $XPos2, $YPos2, array("R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha));
if ($Border)
{
$this->drawLine($XPos1, $YPos1, $XPos1, $YPos2, array("R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $BorderAlpha, "Ticks" => $BorderTicks));
$this->drawLine($XPos2, $YPos1, $XPos2, $YPos2, array("R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $BorderAlpha, "Ticks" => $BorderTicks));
}
if ($AreaName != NULL)
{
$XPos = ($XPos2 -$XPos1) / 2 + $XPos1;
$YPos = ($YPos2 -$YPos1) / 2 + $YPos1;
if ($NameAngle == ZONE_NAME_ANGLE_AUTO)
{
$TxtPos = $this->getTextBox($XPos, $YPos, $this->FontName, $this->FontSize, 0, $AreaName);
$TxtWidth = $TxtPos [1]["X"] - $TxtPos [0]["X"];
if (abs($XPos2 - $XPos1) > $TxtWidth) {
$NameAngle = 0;
}
else {
$NameAngle = 90;
}
}
$this->Shadow = $RestoreShadow;
$this->drawText($XPos, $YPos, $AreaName, array("R" => $NameR, "G" => $NameG, "B" => $NameB, "Alpha" => $NameAlpha, "Angle" => $NameAngle, "Align" => TEXT_ALIGN_MIDDLEMIDDLE));
if ($DisableShadowOnArea) {
$this->Shadow = FALSE;
}
}
$this->Shadow = $RestoreShadow;
return (array("X1" => $XPos1, "X2" => $XPos2));
}
elseif ($Data ["Orientation"] == SCALE_POS_TOPBOTTOM)
{
$XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale [0] * 2) / $XScale [1];
$XPos1 = $this->GraphAreaY1 + $XScale [0] + $XStep * $Value1;
$XPos2 = $this->GraphAreaY1 + $XScale [0] + $XStep * $Value2;
$YPos1 = $this->GraphAreaX1 + $Data ["YMargin"];
$YPos2 = $this->GraphAreaX2 - $Data ["YMargin"];
if ($XPos1 < $this->GraphAreaY1 + $XScale [0]) {
$XPos1 = $this->GraphAreaY1 + $XScale [0];
}
if ($XPos1 > $this->GraphAreaY2 - $XScale [0]) {
$XPos1 = $this->GraphAreaY2 - $XScale [0];
}
if ($XPos2 < $this->GraphAreaY1 + $XScale [0]) {
$XPos2 = $this->GraphAreaY1 + $XScale [0];
}
if ($XPos2 > $this->GraphAreaY2 - $XScale [0]) {
$XPos2 = $this->GraphAreaY2 - $XScale [0];
}
$this->drawFilledRectangle($YPos1, $XPos1, $YPos2, $XPos2, array("R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha));
if ($Border)
{
$this->drawLine($YPos1, $XPos1, $YPos2, $XPos1, array("R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $BorderAlpha, "Ticks" => $BorderTicks));
$this->drawLine($YPos1, $XPos2, $YPos2, $XPos2, array("R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $BorderAlpha, "Ticks" => $BorderTicks));
}
if ($AreaName != NULL)
{
$XPos = ($XPos2 -$XPos1) / 2 + $XPos1;
$YPos = ($YPos2 -$YPos1) / 2 + $YPos1;
$this->Shadow = $RestoreShadow;
$this->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->Shadow = $RestoreShadow;
return (array("X1" => $XPos1, "X2" => $XPos2));
}
}