diff options
Diffstat (limited to 'libs/sparkline/lib/Sparkline_Line.php')
-rw-r--r-- | libs/sparkline/lib/Sparkline_Line.php | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/libs/sparkline/lib/Sparkline_Line.php b/libs/sparkline/lib/Sparkline_Line.php index 292b3b3ed8..16690f4803 100644 --- a/libs/sparkline/lib/Sparkline_Line.php +++ b/libs/sparkline/lib/Sparkline_Line.php @@ -39,12 +39,8 @@ class Sparkline_Line extends Sparkline { // data setting // function SetData($x, $y, $series = 1) { - if(!is_numeric($x)) { - $x = trim($x); - } - if(!is_numeric($y)) { - $y = trim($y); - } + $x = trim($x); + $y = trim($y); $this->Debug("Sparkline_Line :: SetData($x, $y, $series)", DEBUG_SET); @@ -99,18 +95,16 @@ class Sparkline_Line extends Sparkline { } if (!isset($this->yMax)) { - $this->yMax = $this->dataSeriesStats[$series]['yMax']; + $this->yMax = $this->dataSeriesStats[$series]['yMax'] + ($this->yMin * -1); } if (!isset($this->xMax)) { $this->xMax = $this->dataSeriesStats[$series]['xMax']; } - $this->yRange = $this->yMax + ($this->yMin * -1); - for ($i = 0; $i < sizeof($this->dataSeries[$series]); $i++) { - $y = round(($this->dataSeries[$series][$i] + ($this->yMin * -1)) * (($yBound-1) / $this->yRange)); - $x = round($i * $xBound / (sizeof($this->dataSeries[$series]))); + $y = round(($this->dataSeries[$series][$i] + ($this->yMin * -1)) * ($yBound / $this->yMax)); + $x = round($i * $xBound / (sizeof($this->dataSeries[$series]) )); $this->dataSeriesConverted[$series][] = array($x, $y); $this->Debug("Sparkline :: ConvertDataSeries series $series value $i ($x, $y)", DEBUG_SET); } @@ -173,8 +167,8 @@ class Sparkline_Line extends Sparkline { // draw features // while (list(, $v) = each($this->featurePoint)) { - $pxY = round(($v['ptY'] + ($this->yMin * -1)) * ($this->GetGraphHeight() / $this->yRange)); - $pxX = round($v['ptX'] * $this->GetGraphWidth() / sizeof($this->dataSeries[1])); + $pxY = round(($v['ptY'] + ($this->yMin * -1)) * ($this->GetGraphHeight() / $this->yMax)); + $pxX = round($v['ptX'] * $this->GetGraphWidth() / $this->dataSeriesStats[1]['xMax']); $this->DrawCircleFilled($pxX + $this->graphAreaPx[0][0], $pxY + $this->graphAreaPx[0][1], @@ -263,8 +257,8 @@ class Sparkline_Line extends Sparkline { // draw features // while (list(, $v) = each($this->featurePoint)) { - $pxY = round(($v['ptY'] + ($this->yMin * -1)) * ($this->GetGraphHeight() / $this->yRange)); - $pxX = round($v['ptX'] * $this->GetGraphWidth() / sizeof($this->dataSeries[1])); + $pxY = round(($v['ptY'] + ($this->yMin * -1)) * ($this->GetGraphHeight() / $this->yMax)); + $pxX = round($v['ptX'] * $this->GetGraphWidth() / $this->dataSeriesStats[1]['xMax']); $this->DrawCircleFilled($pxX + $this->graphAreaPx[0][0], $pxY + $this->graphAreaPx[0][1], |