function pDraw::drawThresholdArea
Search API
5.x pDraw.class.php | pDraw::drawThresholdArea($Value1, $Value2, $Format = "") |
File
- inc/
pchart/ pchart/ class/ pDraw.class.php, line 2967
Class
Code
function drawThresholdArea($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"] : 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;
$NoMargin = isset($Format ["NoMargin"]) ? $Format ["NoMargin"] : FALSE;
if ($Value1 > $Value2) {
list($Value1, $Value2) = array($Value2, $Value1);
}
$RestoreShadow = $this->Shadow;
if ($DisableShadowOnArea && $this->Shadow) {
$this->Shadow = FALSE;
}
if ($BorderAlpha > 100) {
$BorderAlpha = 100;
}
$Data = $this->DataSet->getData();
$AbscissaMargin = $this->getAbscissaMargin($Data);
if ($NoMargin) {
$AbscissaMargin = 0;
}
if (!isset($Data ["Axis"][$AxisID])) {
return (-1);
}
if ($Data ["Orientation"] == SCALE_POS_LEFTRIGHT)
{
$XPos1 = $this->GraphAreaX1 + $AbscissaMargin;
$XPos2 = $this->GraphAreaX2 - $AbscissaMargin;
$YPos1 = $this->scaleComputeY($Value1, array("AxisID" => $AxisID));
$YPos2 = $this->scaleComputeY($Value2, array("AxisID" => $AxisID));
if ($YPos1 < $this->GraphAreaY1 + $Data ["Axis"][$AxisID]["Margin"]) {
$YPos1 = $this->GraphAreaY1 + $Data ["Axis"][$AxisID]["Margin"];
}
if ($YPos1 > $this->GraphAreaY2 -$Data ["Axis"][$AxisID]["Margin"]) {
$YPos1 = $this->GraphAreaY2 -$Data ["Axis"][$AxisID]["Margin"];
}
if ($YPos2 < $this->GraphAreaY1 + $Data ["Axis"][$AxisID]["Margin"]) {
$YPos2 = $this->GraphAreaY1 + $Data ["Axis"][$AxisID]["Margin"];
}
if ($YPos2 > $this->GraphAreaY2 -$Data ["Axis"][$AxisID]["Margin"]) {
$YPos2 = $this->GraphAreaY2 -$Data ["Axis"][$AxisID]["Margin"];
}
$this->drawFilledRectangle($XPos1, $YPos1, $XPos2, $YPos2, array("R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha));
if ($Border)
{
$this->drawLine($XPos1, $YPos1, $XPos2, $YPos1, array("R" => $BorderR, "G" => $BorderG, "B" => $BorderB, "Alpha" => $BorderAlpha, "Ticks" => $BorderTicks));
$this->drawLine($XPos1, $YPos2, $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;
$this->Shadow = $RestoreShadow;
$this->drawText($XPos, $YPos, $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("Y1" => $YPos1, "Y2" => $YPos2));
}
elseif ($Data ["Orientation"] == SCALE_POS_TOPBOTTOM)
{
$YPos1 = $this->GraphAreaY1 + $AbscissaMargin;
$YPos2 = $this->GraphAreaY2 - $AbscissaMargin;
$XPos1 = $this->scaleComputeY($Value1, array("AxisID" => $AxisID));
$XPos2 = $this->scaleComputeY($Value2, array("AxisID" => $AxisID));
if ($XPos1 < $this->GraphAreaX1 + $Data ["Axis"][$AxisID]["Margin"]) {
$XPos1 = $this->GraphAreaX1 + $Data ["Axis"][$AxisID]["Margin"];
}
if ($XPos1 > $this->GraphAreaX2 -$Data ["Axis"][$AxisID]["Margin"]) {
$XPos1 = $this->GraphAreaX2 -$Data ["Axis"][$AxisID]["Margin"];
}
if ($XPos2 < $this->GraphAreaX1 + $Data ["Axis"][$AxisID]["Margin"]) {
$XPos2 = $this->GraphAreaX1 + $Data ["Axis"][$AxisID]["Margin"];
}
if ($XPos2 > $this->GraphAreaX2 -$Data ["Axis"][$AxisID]["Margin"]) {
$XPos2 = $this->GraphAreaX2 -$Data ["Axis"][$AxisID]["Margin"];
}
$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 = ($YPos2 -$YPos1) / 2 + $YPos1;
$YPos = ($XPos2 -$XPos1) / 2 + $XPos1;
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($YPos, $XPos, $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("Y1" => $XPos1, "Y2" => $XPos2));
}
}