| 1 | efrain | 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 line.
 | 
        
           |  |  | 18 |  *
 | 
        
           |  |  | 19 |  * @copyright  2016 Frédéric Massart - FMCorz.net
 | 
        
           |  |  | 20 |  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 | 
        
           |  |  | 21 |  * @module     core/chart_line
 | 
        
           |  |  | 22 |  */
 | 
        
           |  |  | 23 | define(['core/chart_base'], function(Base) {
 | 
        
           |  |  | 24 |   | 
        
           |  |  | 25 |     /**
 | 
        
           |  |  | 26 |      * Line chart.
 | 
        
           |  |  | 27 |      *
 | 
        
           |  |  | 28 |      * @extends {module:core/chart_base}
 | 
        
           |  |  | 29 |      * @class
 | 
        
           |  |  | 30 |      */
 | 
        
           |  |  | 31 |     function Line() {
 | 
        
           |  |  | 32 |         Base.prototype.constructor.apply(this, arguments);
 | 
        
           |  |  | 33 |     }
 | 
        
           |  |  | 34 |     Line.prototype = Object.create(Base.prototype);
 | 
        
           |  |  | 35 |   | 
        
           |  |  | 36 |     /** @override */
 | 
        
           |  |  | 37 |     Line.prototype.TYPE = 'line';
 | 
        
           |  |  | 38 |   | 
        
           |  |  | 39 |     /**
 | 
        
           |  |  | 40 |      * Whether the line should be smooth or not.
 | 
        
           |  |  | 41 |      *
 | 
        
           |  |  | 42 |      * By default the chart lines are not smooth.
 | 
        
           |  |  | 43 |      *
 | 
        
           |  |  | 44 |      * @type {Bool}
 | 
        
           |  |  | 45 |      * @protected
 | 
        
           |  |  | 46 |      */
 | 
        
           |  |  | 47 |     Line.prototype._smooth = false;
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 |     /** @override */
 | 
        
           |  |  | 50 |     Line.prototype.create = function(Klass, data) {
 | 
        
           |  |  | 51 |         var chart = Base.prototype.create.apply(this, arguments);
 | 
        
           |  |  | 52 |         chart.setSmooth(data.smooth);
 | 
        
           |  |  | 53 |         return chart;
 | 
        
           |  |  | 54 |     };
 | 
        
           |  |  | 55 |   | 
        
           |  |  | 56 |     /**
 | 
        
           |  |  | 57 |      * Get whether the line should be smooth or not.
 | 
        
           |  |  | 58 |      *
 | 
        
           |  |  | 59 |      * @method getSmooth
 | 
        
           |  |  | 60 |      * @returns {Bool}
 | 
        
           |  |  | 61 |      */
 | 
        
           |  |  | 62 |     Line.prototype.getSmooth = function() {
 | 
        
           |  |  | 63 |         return this._smooth;
 | 
        
           |  |  | 64 |     };
 | 
        
           |  |  | 65 |   | 
        
           |  |  | 66 |     /**
 | 
        
           |  |  | 67 |      * Set whether the line should be smooth or not.
 | 
        
           |  |  | 68 |      *
 | 
        
           |  |  | 69 |      * @method setSmooth
 | 
        
           |  |  | 70 |      * @param {Bool} smooth True if the line chart should be smooth, false otherwise.
 | 
        
           |  |  | 71 |      */
 | 
        
           |  |  | 72 |     Line.prototype.setSmooth = function(smooth) {
 | 
        
           |  |  | 73 |         this._smooth = Boolean(smooth);
 | 
        
           |  |  | 74 |     };
 | 
        
           |  |  | 75 |   | 
        
           |  |  | 76 |     return Line;
 | 
        
           |  |  | 77 |   | 
        
           |  |  | 78 | });
 |