You are here

function pScatter::drawScatterThreshold in Visitors 7.2

Same name and namespace in other branches
  1. 7 pChart/class/pScatter.class.php \pScatter::drawScatterThreshold()

File

pChart/class/pScatter.class.php, line 955

Class

pScatter

Code

function drawScatterThreshold($Value, $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"] : 50;
  $Weight = isset($Format["Weight"]) ? $Format["Weight"] : NULL;
  $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : 3;
  $Wide = isset($Format["Wide"]) ? $Format["Wide"] : FALSE;
  $WideFactor = isset($Format["WideFactor"]) ? $Format["WideFactor"] : 5;
  $WriteCaption = isset($Format["WriteCaption"]) ? $Format["WriteCaption"] : FALSE;
  $Caption = isset($Format["Caption"]) ? $Format["Caption"] : NULL;
  $CaptionAlign = isset($Format["CaptionAlign"]) ? $Format["CaptionAlign"] : CAPTION_LEFT_TOP;
  $CaptionOffset = isset($Format["CaptionOffset"]) ? $Format["CaptionOffset"] : 10;
  $CaptionR = isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255;
  $CaptionG = isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255;
  $CaptionB = isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255;
  $CaptionAlpha = isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100;
  $DrawBox = isset($Format["DrawBox"]) ? $Format["DrawBox"] : TRUE;
  $DrawBoxBorder = isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : FALSE;
  $BorderOffset = isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 5;
  $BoxRounded = isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : TRUE;
  $RoundedRadius = isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 3;
  $BoxR = isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
  $BoxG = isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
  $BoxB = isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
  $BoxAlpha = isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 20;
  $BoxSurrounding = isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
  $BoxBorderR = isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 255;
  $BoxBorderG = isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 255;
  $BoxBorderB = isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 255;
  $BoxBorderAlpha = isset($Format["BoxBorderAlpha"]) ? $Format["BoxBorderAlpha"] : 100;
  $CaptionSettings = array(
    "DrawBox" => $DrawBox,
    "DrawBoxBorder" => $DrawBoxBorder,
    "BorderOffset" => $BorderOffset,
    "BoxRounded" => $BoxRounded,
    "RoundedRadius" => $RoundedRadius,
    "BoxR" => $BoxR,
    "BoxG" => $BoxG,
    "BoxB" => $BoxB,
    "BoxAlpha" => $BoxAlpha,
    "BoxSurrounding" => $BoxSurrounding,
    "BoxBorderR" => $BoxBorderR,
    "BoxBorderG" => $BoxBorderG,
    "BoxBorderB" => $BoxBorderB,
    "BoxBorderAlpha" => $BoxBorderAlpha,
    "R" => $CaptionR,
    "G" => $CaptionG,
    "B" => $CaptionB,
    "Alpha" => $CaptionAlpha,
  );
  if ($Caption == NULL) {
    $Caption = $Value;
  }
  $Data = $this->pDataObject
    ->getData();
  if (!isset($Data["Axis"][$AxisID])) {
    return -1;
  }
  if ($Data["Axis"][$AxisID]["Identity"] == AXIS_Y) {
    $X1 = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"];
    $X2 = $this->pChartObject->GraphAreaX2 - $Data["Axis"][$AxisID]["Margin"];
    $Y = $this
      ->getPosArray($Value, $AxisID);
    $this->pChartObject
      ->drawLine($X1, $Y, $X2, $Y, array(
      "R" => $R,
      "G" => $G,
      "B" => $B,
      "Alpha" => $Alpha,
      "Ticks" => $Ticks,
      "Weight" => $Weight,
    ));
    if ($Wide) {
      $this->pChartObject
        ->drawLine($X1, $Y - 1, $X2, $Y - 1, array(
        "R" => $R,
        "G" => $G,
        "B" => $B,
        "Alpha" => $Alpha / $WideFactor,
        "Ticks" => $Ticks,
      ));
      $this->pChartObject
        ->drawLine($X1, $Y + 1, $X2, $Y + 1, array(
        "R" => $R,
        "G" => $G,
        "B" => $B,
        "Alpha" => $Alpha / $WideFactor,
        "Ticks" => $Ticks,
      ));
    }
    if ($WriteCaption) {
      if ($CaptionAlign == CAPTION_LEFT_TOP) {
        $X = $this->pChartObject->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"] + $CaptionOffset;
        $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLELEFT;
      }
      else {
        $X = $this->pChartObject->GraphAreaX2 - $Data["Axis"][$AxisID]["Margin"] - $CaptionOffset;
        $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLERIGHT;
      }
      $this->pChartObject
        ->drawText($X, $Y, $Caption, $CaptionSettings);
    }
    return array(
      "Y" => $Y,
    );
  }
  elseif ($Data["Axis"][$AxisID]["Identity"] == AXIS_X) {
    $X = $this
      ->getPosArray($Value, $AxisID);
    $Y1 = $this->pChartObject->GraphAreaY1 + $Data["Axis"][$AxisID]["Margin"];
    $Y2 = $this->pChartObject->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"];
    $this->pChartObject
      ->drawLine($X, $Y1, $X, $Y2, array(
      "R" => $R,
      "G" => $G,
      "B" => $B,
      "Alpha" => $Alpha,
      "Ticks" => $Ticks,
      "Weight" => $Weight,
    ));
    if ($Wide) {
      $this->pChartObject
        ->drawLine($X - 1, $Y1, $X - 1, $Y2, array(
        "R" => $R,
        "G" => $G,
        "B" => $B,
        "Alpha" => $Alpha / $WideFactor,
        "Ticks" => $Ticks,
      ));
      $this->pChartObject
        ->drawLine($X + 1, $Y1, $X + 1, $Y2, array(
        "R" => $R,
        "G" => $G,
        "B" => $B,
        "Alpha" => $Alpha / $WideFactor,
        "Ticks" => $Ticks,
      ));
    }
    if ($WriteCaption) {
      if ($CaptionAlign == CAPTION_LEFT_TOP) {
        $Y = $this->pChartObject->GraphAreaY1 + $Data["Axis"][$AxisID]["Margin"] + $CaptionOffset;
        $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE;
      }
      else {
        $Y = $this->pChartObject->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"] - $CaptionOffset;
        $CaptionSettings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
      }
      $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE;
      $this->pChartObject
        ->drawText($X, $Y, $Caption, $CaptionSettings);
    }
    return array(
      "X" => $X,
    );
  }
}