2 // This file is part of Moodle - http://moodle.org/
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
21 * @copyright 2016 Frédéric Massart - FMCorz.net
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
36 * @copyright 2016 Frédéric Massart - FMCorz.net
37 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39 class chart_axis
implements JsonSerializable
{
41 /** Default axis position. */
42 const POS_DEFAULT
= null;
43 /** Bottom axis position. */
44 const POS_BOTTOM
= 'bottom';
45 /** Left axis position. */
46 const POS_LEFT
= 'left';
47 /** Right axis position. */
48 const POS_RIGHT
= 'right';
49 /** Top axis position. */
50 const POS_TOP
= 'top';
52 /** @var string The axis label. */
53 protected $label = null;
54 /** @var string[] The axis labels, tick values. */
55 protected $labels = null;
56 /** @var float The maximum tick value. */
57 protected $max = null;
58 /** @var float The minimum tick value. */
59 protected $min = null;
60 /** @var string The axis position. */
61 protected $position = self
::POS_DEFAULT
;
62 /** @var float The stepsize between ticks. */
63 protected $stepsize = null;
68 * Must not take any argument.
70 public function __construct() {
78 public function get_label() {
87 public function get_labels() {
96 public function get_max() {
105 public function get_min() {
110 * Get the axis position.
114 public function get_position() {
115 return $this->position
;
123 public function get_stepsize() {
124 return $this->stepsize
;
128 * Serialize the object.
132 public function jsonSerialize(): array {
134 'label' => $this->label
,
135 'labels' => $this->labels
,
138 'position' => $this->position
,
139 'stepSize' => $this->stepsize
,
146 * @param string $label The label.
148 public function set_label($label) {
149 $this->label
= $label;
155 * @param string[] $labels The labels.
157 public function set_labels($labels) {
158 $this->labels
= $labels;
164 * @param float $max The max value.
166 public function set_max($max) {
173 * @param float $min The min value.
175 public function set_min($min) {
182 * @param string $position Use constant self::POS_*.
184 public function set_position($position) {
185 $this->position
= $position;
191 * @param float $stepsize The step size.
193 public function set_stepsize($stepsize) {
194 $this->stepsize
= $stepsize;