function pDraw::drawZoneChart

5.x pDraw.class.php pDraw::drawZoneChart($SerieA, $SerieB, $Format = NULL)

File

inc/pchart/pchart/class/pDraw.class.php, line 3836

Class

pDraw

Code

function drawZoneChart($SerieA, $SerieB, $Format = NULL) 
 {
  $AxisID = isset($Format ["AxisID"]) ? $Format ["AxisID"] : 0;
  $LineR = isset($Format ["LineR"]) ? $Format ["LineR"] : 150;
  $LineG = isset($Format ["LineG"]) ? $Format ["LineG"] : 150;
  $LineB = isset($Format ["LineB"]) ? $Format ["LineB"] : 150;
  $LineAlpha = isset($Format ["LineAlpha"]) ? $Format ["LineAlpha"] : 50;
  $LineTicks = isset($Format ["LineTicks"]) ? $Format ["LineTicks"] : 1;
  $AreaR = isset($Format ["AreaR"]) ? $Format ["AreaR"] : 150;
  $AreaG = isset($Format ["AreaG"]) ? $Format ["AreaG"] : 150;
  $AreaB = isset($Format ["AreaB"]) ? $Format ["AreaB"] : 150;
  $AreaAlpha = isset($Format ["AreaAlpha"]) ? $Format ["AreaAlpha"] : 5;

  $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;

  $Data = $this->DataSet->getData();
  if (!isset($Data ["Series"][$SerieA]["Data"]) || !isset($Data ["Series"][$SerieB]["Data"])) {
    return (0);
  }
  $SerieAData = $Data ["Series"][$SerieA]["Data"];
  $SerieBData = $Data ["Series"][$SerieB]["Data"];

  list($XMargin, $XDivs) = $this->scaleGetXSettings();

  $Mode = $Data ["Axis"][$AxisID]["Display"];
  $Format = $Data ["Axis"][$AxisID]["Format"];
  $Unit = $Data ["Axis"][$AxisID]["Unit"];

  $PosArrayA = $this->scaleComputeY($SerieAData, array("AxisID" => $AxisID));
  $PosArrayB = $this->scaleComputeY($SerieBData, array("AxisID" => $AxisID));
  if (count($PosArrayA) != count($PosArrayB)) {
    return (0);
  }

  if ($Data ["Orientation"] == SCALE_POS_LEFTRIGHT) 
   {
    if ($XDivs == 0) {
      $XStep = ($this->GraphAreaX2 -$this->GraphAreaX1) / 4;
    }
    else {
      $XStep = ($this->GraphAreaX2 -$this->GraphAreaX1 -$XMargin * 2) / $XDivs;
    }
    $X = $this->GraphAreaX1 + $XMargin;
    $LastX = NULL;
    $LastY = NULL;

    $LastX = NULL;
    $LastY1 = NULL;
    $LastY2 = NULL;
    $BoundsA = "";
    $BoundsB = "";
    foreach ($PosArrayA as $Key => $Y1) 
     {
      $Y2 = $PosArrayB [$Key];

      $BoundsA [] = $X;
      $BoundsA [] = $Y1;
      $BoundsB [] = $X;
      $BoundsB [] = $Y2;

      $LastX = $X;
      $LastY1 = $Y1;
      $LastY2 = $Y2;

      $X = $X + $XStep;
    }
    $Bounds = array_merge($BoundsA, $this->reversePlots($BoundsB));
    $this->drawPolygonChart($Bounds, array("R" => $AreaR, "G" => $AreaG, "B" => $AreaB, "Alpha" => $AreaAlpha));

    for ($i = 0; $i <= count($BoundsA) -4; $i = $i + 2) 
     {
      $this->drawLine($BoundsA [$i], $BoundsA [$i + 1], $BoundsA [$i + 2], $BoundsA [$i + 3], array("R" => $LineR, "G" => $LineG, "B" => $LineB, "Alpha" => $LineAlpha, "Ticks" => $LineTicks));
      $this->drawLine($BoundsB [$i], $BoundsB [$i + 1], $BoundsB [$i + 2], $BoundsB [$i + 3], array("R" => $LineR, "G" => $LineG, "B" => $LineB, "Alpha" => $LineAlpha, "Ticks" => $LineTicks));
    }
  }
  else 
   {
    if ($XDivs == 0) {
      $YStep = ($this->GraphAreaY2 -$this->GraphAreaY1) / 4;
    }
    else {
      $YStep = ($this->GraphAreaY2 -$this->GraphAreaY1 -$XMargin * 2) / $XDivs;
    }
    $Y = $this->GraphAreaY1 + $XMargin;
    $LastX = NULL;
    $LastY = NULL;

    $LastY = NULL;
    $LastX1 = NULL;
    $LastX2 = NULL;
    $BoundsA = "";
    $BoundsB = "";
    foreach ($PosArrayA as $Key => $X1) 
     {
      $X2 = $PosArrayB [$Key];

      $BoundsA [] = $X1;
      $BoundsA [] = $Y;
      $BoundsB [] = $X2;
      $BoundsB [] = $Y;

      $LastY = $Y;
      $LastX1 = $X1;
      $LastX2 = $X2;

      $Y = $Y + $YStep;
    }
    $Bounds = array_merge($BoundsA, $this->reversePlots($BoundsB));
    $this->drawPolygonChart($Bounds, array("R" => $AreaR, "G" => $AreaG, "B" => $AreaB, "Alpha" => $AreaAlpha));

    for ($i = 0; $i <= count($BoundsA) -4; $i = $i + 2) 
     {
      $this->drawLine($BoundsA [$i], $BoundsA [$i + 1], $BoundsA [$i + 2], $BoundsA [$i + 3], array("R" => $LineR, "G" => $LineG, "B" => $LineB, "Alpha" => $LineAlpha, "Ticks" => $LineTicks));
      $this->drawLine($BoundsB [$i], $BoundsB [$i + 1], $BoundsB [$i + 2], $BoundsB [$i + 3], array("R" => $LineR, "G" => $LineG, "B" => $LineB, "Alpha" => $LineAlpha, "Ticks" => $LineTicks));
    }
  }
}