function pDraw::scaleComputeY in Visitors 7.2
Same name and namespace in other branches
- 7 pChart/class/pDraw.class.php \pDraw::scaleComputeY()
17 calls to pDraw::scaleComputeY()
- pDraw::drawAreaChart in pChart/
class/ pDraw.class.php - pDraw::drawBarChart in pChart/
class/ pDraw.class.php - pDraw::drawBestFit in pChart/
class/ pDraw.class.php - pDraw::drawDerivative in pChart/
class/ pDraw.class.php - pDraw::drawFilledSplineChart in pChart/
class/ pDraw.class.php
File
- pChart/
class/ pDraw.class.php, line 3087
Class
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;
}
}