[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 // This file is part of Moodle - http://moodle.org/ 2 // 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. 7 // 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. 12 // 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/>. 15 16 /** 17 * Chart bar. 18 * 19 * @package core 20 * @copyright 2016 Frédéric Massart - FMCorz.net 21 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 22 * @module core/chart_bar 23 */ 24 define(['core/chart_base'], function(Base) { 25 26 /** 27 * Bar chart. 28 * 29 * @alias module:core/chart_bar 30 * @extends {module:core/chart_base} 31 * @class 32 */ 33 function Bar() { 34 Base.prototype.constructor.apply(this, arguments); 35 } 36 Bar.prototype = Object.create(Base.prototype); 37 38 /** 39 * Whether the bars should be displayed horizontally or not. 40 * 41 * @type {Bool} 42 * @protected 43 */ 44 Bar.prototype._horizontal = false; 45 46 /** @override */ 47 Bar.prototype.TYPE = 'bar'; 48 49 /** @override */ 50 Bar.prototype.create = function(Klass, data) { 51 var chart = Base.prototype.create.apply(this, arguments); 52 chart.setHorizontal(data.horizontal); 53 return chart; 54 }; 55 56 /** @override */ 57 Bar.prototype._setDefaults = function() { 58 Base.prototype._setDefaults.apply(this, arguments); 59 var axis = this.getYAxis(0, true); 60 axis.setMin(0); 61 }; 62 63 /** 64 * Get whether the bars should be displayed horizontally or not. 65 * 66 * @returns {Bool} 67 */ 68 Bar.prototype.getHorizontal = function() { 69 return this._horizontal; 70 }; 71 72 /** 73 * Set whether the bars should be displayed horizontally or not. 74 * 75 * It sets the X Axis to zero if the min value is null. 76 * 77 * @param {Bool} horizontal True if the bars should be displayed horizontally, false otherwise. 78 */ 79 Bar.prototype.setHorizontal = function(horizontal) { 80 var axis = this.getXAxis(0, true); 81 if (axis.getMin() === null) { 82 axis.setMin(0); 83 } 84 this._horizontal = Boolean(horizontal); 85 }; 86 87 return Bar; 88 89 });
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |