Merge branch 'MDL-67410-37' of https://github.com/felicemcc/moodle into MOODLE_37_STABLE
[moodle.git] / lib / amd / src / chart_output_base.js
blobac256e7bfa84f1a0d737c76173fb94c464dd76a4
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.
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/>.
16 /**
17  * Chart output base.
18  *
19  * This takes a chart object and draws it.
20  *
21  * @package    core
22  * @copyright  2016 Frédéric Massart - FMCorz.net
23  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24  * @module     core/chart_output_base
25  */
26 define(['jquery'], function($) {
28     /**
29      * Chart output base.
30      *
31      * The constructor of an output class must instantly generate and display the
32      * chart. It is also the responsability of the output module to check that
33      * the node received is of the appropriate type, if not a new node can be
34      * added within.
35      *
36      * The output module has total control over the content of the node and can
37      * clear it or output anything to it at will. A node should not be shared by
38      * two simultaneous output modules.
39      *
40      * @class
41      * @alias module:core/chart_output_base
42      * @param {Node} node The node to output with/in.
43      * @param {Chart} chart A chart object.
44      */
45     function Base(node, chart) {
46         this._node = $(node);
47         this._chart = chart;
48     }
50     /**
51      * Update method.
52      *
53      * This is the public method through which an output instance in informed
54      * that the chart instance has been updated and they need to update the
55      * chart rendering.
56      *
57      * @abstract
58      * @return {Void}
59      */
60     Base.prototype.update = function() {
61         throw new Error('Not supported.');
62     };
64     return Base;
66 });