MDL-79915 backup: Improve the Restore main page
[moodle.git] / lib / classes / chart_axis.php
blob7e3be171f418eeee4a76b55661ee702a2672d6a4
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
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.
8 //
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/>.
17 /**
18 * Chart axis.
20 * @package core
21 * @copyright 2016 Frédéric Massart - FMCorz.net
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 namespace core;
26 defined('MOODLE_INTERNAL') || die();
28 use coding_exception;
29 use JsonSerializable;
30 use renderable;
32 /**
33 * Chart axis class.
35 * @package core
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;
65 /**
66 * Constructor.
68 * Must not take any argument.
70 public function __construct() {
73 /**
74 * Get the label.
76 * @return string
78 public function get_label() {
79 return $this->label;
82 /**
83 * Get the labels.
85 * @return string[]
87 public function get_labels() {
88 return $this->labels;
91 /**
92 * Get the max value.
94 * @return float
96 public function get_max() {
97 return $this->max;
101 * Get the min value.
103 * @return float
105 public function get_min() {
106 return $this->min;
110 * Get the axis position.
112 * @return string
114 public function get_position() {
115 return $this->position;
119 * Get the step size.
121 * @return float
123 public function get_stepsize() {
124 return $this->stepsize;
128 * Serialize the object.
130 * @return array
132 public function jsonSerialize(): array {
133 return [
134 'label' => $this->label,
135 'labels' => $this->labels,
136 'max' => $this->max,
137 'min' => $this->min,
138 'position' => $this->position,
139 'stepSize' => $this->stepsize,
144 * Set the label.
146 * @param string $label The label.
148 public function set_label($label) {
149 $this->label = $label;
153 * Set the labels.
155 * @param string[] $labels The labels.
157 public function set_labels($labels) {
158 $this->labels = $labels;
162 * Set the max value.
164 * @param float $max The max value.
166 public function set_max($max) {
167 $this->max = $max;
171 * Set the min value.
173 * @param float $min The min value.
175 public function set_min($min) {
176 $this->min = $min;
180 * Set the position.
182 * @param string $position Use constant self::POS_*.
184 public function set_position($position) {
185 $this->position = $position;
189 * Set the step size.
191 * @param float $stepsize The step size.
193 public function set_stepsize($stepsize) {
194 $this->stepsize = $stepsize;