You are here

function pBubble::writeBubbleLabel in Visitors 7

Same name and namespace in other branches
  1. 7.2 pChart/class/pBubble.class.php \pBubble::writeBubbleLabel()

File

pChart/class/pBubble.class.php, line 254

Class

pBubble

Code

function writeBubbleLabel($SerieName, $SerieWeightName, $Points, $Format = "") {
  $OverrideTitle = isset($Format["OverrideTitle"]) ? $Format["OverrideTitle"] : NULL;
  $DrawPoint = isset($Format["DrawPoint"]) ? $Format["DrawPoint"] : LABEL_POINT_BOX;
  if (!is_array($Points)) {
    $Point = $Points;
    $Points = "";
    $Points[] = $Point;
  }
  $Data = $this->pDataObject
    ->getData();
  $Palette = $this->pDataObject
    ->getPalette();
  if (!isset($Data["Series"][$SerieName]) || !isset($Data["Series"][$SerieWeightName])) {
    return 0;
  }
  list($XMargin, $XDivs) = $this->pChartObject
    ->scaleGetXSettings();
  $AxisID = $Data["Series"][$SerieName]["Axis"];
  $AxisMode = $Data["Axis"][$AxisID]["Display"];
  $AxisFormat = $Data["Axis"][$AxisID]["Format"];
  $AxisUnit = $Data["Axis"][$AxisID]["Unit"];
  $XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2) / $XDivs;
  $X = $this->pChartObject->GraphAreaX1 + $XMargin;
  $Y = $this->pChartObject->GraphAreaY1 + $XMargin;
  $Color = array(
    "R" => $Data["Series"][$SerieName]["Color"]["R"],
    "G" => $Data["Series"][$SerieName]["Color"]["G"],
    "B" => $Data["Series"][$SerieName]["Color"]["B"],
    "Alpha" => $Data["Series"][$SerieName]["Color"]["Alpha"],
  );
  foreach ($Points as $Key => $Point) {
    $Value = $Data["Series"][$SerieName]["Data"][$Point];
    $PosArray = $this->pChartObject
      ->scaleComputeY($Value, array(
      "AxisID" => $AxisID,
    ));
    if (isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Point])) {
      $Abscissa = $Data["Series"][$Data["Abscissa"]]["Data"][$Point] . " : ";
    }
    else {
      $Abscissa = "";
    }
    $Value = $this->pChartObject
      ->scaleFormat($Value, $AxisMode, $AxisFormat, $AxisUnit);
    $Weight = $Data["Series"][$SerieWeightName]["Data"][$Point];
    $Caption = $Abscissa . $Value . " / " . $Weight;
    if (isset($Data["Series"][$SerieName]["Description"])) {
      $Description = $Data["Series"][$SerieName]["Description"];
    }
    else {
      $Description = "No description";
    }
    $Series = "";
    $Series[] = array(
      "Format" => $Color,
      "Caption" => $Caption,
    );
    if ($Data["Orientation"] == SCALE_POS_LEFTRIGHT) {
      if ($XDivs == 0) {
        $XStep = 0;
      }
      else {
        $XStep = ($this->pChartObject->GraphAreaX2 - $this->pChartObject->GraphAreaX1 - $XMargin * 2) / $XDivs;
      }
      $X = floor($X + $Point * $XStep);
      $Y = floor($PosArray);
    }
    else {
      if ($XDivs == 0) {
        $YStep = 0;
      }
      else {
        $YStep = ($this->pChartObject->GraphAreaY2 - $this->pChartObject->GraphAreaY1 - $XMargin * 2) / $XDivs;
      }
      $X = floor($PosArray);
      $Y = floor($Y + $Point * $YStep);
    }
    if ($DrawPoint == LABEL_POINT_CIRCLE) {
      $this->pChartObject
        ->drawFilledCircle($X, $Y, 3, array(
        "R" => 255,
        "G" => 255,
        "B" => 255,
        "BorderR" => 0,
        "BorderG" => 0,
        "BorderB" => 0,
      ));
    }
    elseif ($DrawPoint == LABEL_POINT_BOX) {
      $this->pChartObject
        ->drawFilledRectangle($X - 2, $Y - 2, $X + 2, $Y + 2, array(
        "R" => 255,
        "G" => 255,
        "B" => 255,
        "BorderR" => 0,
        "BorderG" => 0,
        "BorderB" => 0,
      ));
    }
    $this->pChartObject
      ->drawLabelBox($X, $Y - 3, $Description, $Series, $Format);
  }
}