2
/* Libchart - PHP chart library
3
* Copyright (C) 2005-2008 Jean-Marc Tr�meaux (jm.tremeaux at gmail.com)
5
* This program is free software: you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation, either version 3 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
* Object representing the bounds of a dataset (its minimal and maximal values) on its vertical axis.
22
* The bounds are automatically calculated from a XYDataSet or XYSeriesDataSet.
23
* Default (calculated) bounds can be overriden using the setLowerBound() and setUpperBound() methods.
25
* @author Jean-Marc Tr�meaux (jm.tremeaux at gmail.com)
26
* Created on 25 july 2007
30
* Manually set lower bound, overrides the value calculated by computeBound().
32
private $lowerBound = null;
35
* Manually set upper bound, overrides the value calculated by computeBound().
37
private $upperBound = null;
42
private $yMinValue = null;
47
private $yMaxValue = null;
50
* Compute the boundaries on the axis.
52
* @param dataSet The data set
54
public function computeBound($dataSet) {
55
// Check if the data set is empty
58
if ($dataSet instanceof XYDataSet) {
59
$pointList = $dataSet->getPointList();
60
$dataSetEmpty = count($pointList) == 0;
63
// Process it as a serie
65
array_push($serieList, $dataSet);
67
} else if ($dataSet instanceof XYSeriesDataSet) {
68
$serieList = $dataSet->getSerieList();
69
if (count($serieList) > 0) {
70
$serie = current($serieList);
71
$dataSetEmpty = count($serie) == 0;
74
die("Error: unknown dataset type");
77
// If the dataset is empty, default some bounds
81
// Compute lower and upper bound on the value axis
85
foreach ($serieList as $serie) {
86
foreach ($serie->getPointList() as $point) {
105
// If user specified bounds and they are actually greater than computer bounds, override computed bounds
106
if (isset($this->lowerBound) && $this->lowerBound < $yMin) {
107
$this->yMinValue = $this->lowerBound;
109
$this->yMinValue = $yMin;
112
if (isset($this->upperBound) && $this->upperBound > $yMax) {
113
$this->yMaxValue = $this->upperBound;
115
$this->yMaxValue = $yMax;
120
* Getter of yMinValue.
124
public function getYMinValue() {
125
return $this->yMinValue;
129
* Getter of yMaxValue.
133
public function getYMaxValue() {
134
return $this->yMaxValue;
138
* Set manually the lower boundary value (overrides the automatic formatting).
139
* Typical usage is to set the bars starting from zero.
141
* @param double lower boundary value
143
public function setLowerBound($lowerBound) {
144
$this->lowerBound = $lowerBound;
148
* Set manually the upper boundary value (overrides the automatic formatting).
150
* @param double upper boundary value
152
public function setUpperBound($upperBound) {
153
$this->upperBound = $upperBound;
b'\\ No newline at end of file'