1 // This file is part of Moodle - http://moodle.org/
3 // Moodle is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
8 // Moodle is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
20 * @copyright 2016 Frédéric Massart - FMCorz.net
21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 define([], function() {
29 // Please eslint no-empty-function.
32 Axis.prototype.POS_DEFAULT = null;
33 Axis.prototype.POS_BOTTOM = 'bottom';
34 Axis.prototype.POS_LEFT = 'left';
35 Axis.prototype.POS_RIGHT = 'right';
36 Axis.prototype.POS_TOP = 'top';
38 Axis.prototype._label = null;
39 Axis.prototype._position = null;
40 Axis.prototype._stepSize = null;
42 Axis.prototype.create = function(obj) {
44 s.setPosition(obj.position);
45 s.setLabel(obj.label);
46 s.setStepSize(obj.stepSize);
50 Axis.prototype.getLabel = function() {
54 Axis.prototype.getPosition = function() {
55 return this._position;
58 Axis.prototype.getStepSize = function() {
59 return this._stepSize;
62 Axis.prototype.setLabel = function(label) {
63 this._label = label || null;
66 Axis.prototype.setPosition = function(position) {
67 if (position != this.POS_DEFAULT
68 && position != this.POS_BOTTOM
69 && position != this.POS_LEFT
70 && position != this.POS_RIGHT
71 && position != this.POS_TOP) {
72 throw new Error('Invalid axis position.');
74 this._position = position;
77 Axis.prototype.setStepSize = function(stepSize) {
78 if (typeof stepSize === 'undefined' || stepSize === null) {
80 } else if (isNaN(Number(stepSize))) {
81 throw new Error('Value for stepSize is not a number.');
83 stepSize = Number(stepSize);
86 this._stepSize = stepSize;