| 1 |
<?php |
| 2 |
/** |
| 3 |
* Copyright (C) 2019-2022 Graham Breach |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU Lesser 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. |
| 9 |
* |
| 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 Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
/** |
| 19 |
* For more information, please contact <graham@goat1000.com> |
| 20 |
*/ |
| 21 |
|
| 22 |
namespace Goat1000\SVGGraph; |
| 23 |
|
| 24 |
/** |
| 25 |
* Implements MultiGraph setup and overrides some Graph functions |
| 26 |
*/ |
| 27 |
trait MultiGraphTrait { |
| 28 |
|
| 29 |
/** |
| 30 |
* Construct MultiGraph when setting values |
| 31 |
*/ |
| 32 |
public function values($values) |
| 33 |
{ |
| 34 |
parent::values($values); |
| 35 |
if(!$this->values->error) { |
| 36 |
$this->multi_graph = new MultiGraph($this->values, |
| 37 |
$this->getOption('force_assoc'), |
| 38 |
$this->getOption('datetime_keys'), |
| 39 |
$this->getOption('require_integer_keys')); |
| 40 |
|
| 41 |
$this->multi_graph->setEnabledDatasets($this->getOption('dataset')); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
public function getMinValue() |
| 46 |
{ |
| 47 |
return $this->multi_graph->getMinValue(); |
| 48 |
} |
| 49 |
|
| 50 |
public function getMaxValue() |
| 51 |
{ |
| 52 |
return $this->multi_graph->getMaxValue(); |
| 53 |
} |
| 54 |
|
| 55 |
public function getMinKey() |
| 56 |
{ |
| 57 |
return $this->multi_graph->getMinKey(); |
| 58 |
} |
| 59 |
|
| 60 |
public function getMaxKey() |
| 61 |
{ |
| 62 |
return $this->multi_graph->getMaxKey(); |
| 63 |
} |
| 64 |
|
| 65 |
public function getKey($i) |
| 66 |
{ |
| 67 |
return $this->multi_graph->getKey($i); |
| 68 |
} |
| 69 |
|
| 70 |
protected function setup() |
| 71 |
{ |
| 72 |
$dataset_count = count($this->multi_graph); |
| 73 |
$this->colourSetup($this->multi_graph->itemsCount(-1), $dataset_count); |
| 74 |
} |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
|