You are here

function pData::setSerieOnAxis in Visitors 7.2

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

File

pChart/class/pData.class.php, line 452

Class

pData

Code

function setSerieOnAxis($Series, $AxisID) {
  if (!is_array($Series)) {
    $Series = $this
      ->convertToArray($Series);
  }
  foreach ($Series as $Key => $Serie) {
    $PreviousAxis = $this->Data["Series"][$Serie]["Axis"];

    /* Create missing axis */
    if (!isset($this->Data["Axis"][$AxisID])) {
      $this->Data["Axis"][$AxisID]["Position"] = AXIS_POSITION_LEFT;
      $this->Data["Axis"][$AxisID]["Identity"] = AXIS_Y;
    }
    $this->Data["Series"][$Serie]["Axis"] = $AxisID;

    /* Cleanup unused axis */
    $Found = FALSE;
    foreach ($this->Data["Series"] as $SerieName => $Values) {
      if ($Values["Axis"] == $PreviousAxis) {
        $Found = TRUE;
      }
    }
    if (!$Found) {
      unset($this->Data["Axis"][$PreviousAxis]);
    }
  }
}