function pDraw::scaleComputeY

5.x pDraw.class.php pDraw::scaleComputeY($Values, $Option = "", $ReturnOnly0Height = FALSE)
17 calls to pDraw::scaleComputeY()
pDraw::drawAreaChart in inc/pchart/pchart/class/pDraw.class.php
pDraw::drawBarChart in inc/pchart/pchart/class/pDraw.class.php
pDraw::drawBestFit in inc/pchart/pchart/class/pDraw.class.php
pDraw::drawDerivative in inc/pchart/pchart/class/pDraw.class.php
pDraw::drawFilledSplineChart in inc/pchart/pchart/class/pDraw.class.php

... See full list

File

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

Class

pDraw

Code

function scaleComputeY($Values, $Option = "", $ReturnOnly0Height = FALSE) 
 {
  $AxisID = isset($Option ["AxisID"]) ? $Option ["AxisID"] : 0;
  $SerieName = isset($Option ["SerieName"]) ? $Option ["SerieName"] : NULL;

  $Data = $this->DataSet->getData();
  if (!isset($Data ["Axis"][$AxisID])) {
    return (-1);
  }

  if ($SerieName != NULL) {
    $AxisID = $Data ["Series"][$SerieName]["Axis"];
  }
  if (!is_array($Values)) {
    $tmp = $Values;
    $Values = "";
    $Values [0] = $tmp;
  }

  $Result = "";
  if ($Data ["Orientation"] == SCALE_POS_LEFTRIGHT) 
   {
    $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Data ["Axis"][$AxisID]["Margin"] * 2;
    $ScaleHeight = $Data ["Axis"][$AxisID]["ScaleMax"] - $Data ["Axis"][$AxisID]["ScaleMin"];
    $Step = $Height / $ScaleHeight;

    if ($ReturnOnly0Height) 
     {
      foreach ($Values as $Key => $Value) {
        if ($Value == VOID) {
          $Result [] = VOID;
        }
        else {
          $Result [] = $Step * $Value;
        }
      }
    }
    else 
     {
      foreach ($Values as $Key => $Value) {
        if ($Value == VOID) {
          $Result [] = VOID;
        }
        else {
          $Result [] = $this->GraphAreaY2 - $Data ["Axis"][$AxisID]["Margin"] - ($Step * ($Value -$Data ["Axis"][$AxisID]["ScaleMin"]));
        }
      }
    }
  }
  else 
   {
    $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Data ["Axis"][$AxisID]["Margin"] * 2;
    $ScaleWidth = $Data ["Axis"][$AxisID]["ScaleMax"] - $Data ["Axis"][$AxisID]["ScaleMin"];
    $Step = $Width / $ScaleWidth;

    if ($ReturnOnly0Height) 
     {
      foreach ($Values as $Key => $Value) {
        if ($Value == VOID) {
          $Result [] = VOID;
        }
        else {
          $Result [] = $Step * $Value;
        }
      }
    }
    else 
     {
      foreach ($Values as $Key => $Value) {
        if ($Value == VOID) {
          $Result [] = VOID;
        }
        else {
          $Result [] = $this->GraphAreaX1 + $Data ["Axis"][$AxisID]["Margin"] + ($Step * ($Value -$Data ["Axis"][$AxisID]["ScaleMin"]));
        }
      }
    }
  }

  if (count($Result) == 1) {
    return ($Result [0]);
  }
  else {
    return ($Result);
  }
}