| 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 |
trait Grouped3DGraphTrait { |
| 25 |
|
| 26 |
use GroupedBarTrait; |
| 27 |
|
| 28 |
/** |
| 29 |
* Override AdjustAxes to change depth |
| 30 |
*/ |
| 31 |
protected function adjustAxes(&$x_len, &$y_len) |
| 32 |
{ |
| 33 |
/** |
| 34 |
* The depth is roughly 1/$num - but it must also take into account the |
| 35 |
* bar and group spacing, which is where things get messy |
| 36 |
*/ |
| 37 |
$ends = $this->getAxisEnds(); |
| 38 |
$num = $ends['k_max'][0] - $ends['k_min'][0] + 1; |
| 39 |
|
| 40 |
$block = $x_len / $num; |
| 41 |
$datasets = $this->multi_graph->getEnabledDatasets(); |
| 42 |
$group = count($datasets); |
| 43 |
$a = $this->getOption('bar_space'); |
| 44 |
$b = $this->getOption('group_space'); |
| 45 |
$c = (($block) - $a - ($group - 1) * $b) / $group; |
| 46 |
$d = ($a + $c) / $block; |
| 47 |
$this->depth = $d; |
| 48 |
return parent::adjustAxes($x_len, $y_len); |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
|