{"version":3,"file":"chart_series.min.js","sources":["../src/chart_series.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Chart series.\n *\n * @copyright 2016 Frédéric Massart - FMCorz.net\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n * @module core/chart_series\n */\ndefine([], function() {\n\n /**\n * Chart data series.\n *\n * @class\n * @param {String} label The series label.\n * @param {Number[]} values The values.\n */\n function Series(label, values) {\n if (typeof label !== 'string') {\n throw new Error('Invalid label for series.');\n\n } else if (typeof values !== 'object') {\n throw new Error('Values for a series must be an array.');\n\n } else if (values.length < 1) {\n throw new Error('Invalid values received for series.');\n }\n\n this._colors = [];\n this._label = label;\n this._values = values;\n }\n\n /**\n * The default type of series.\n *\n * @type {Null}\n * @const\n */\n Series.prototype.TYPE_DEFAULT = null;\n\n /**\n * Type of series 'line'.\n *\n * @type {String}\n * @const\n */\n Series.prototype.TYPE_LINE = 'line';\n\n /**\n * The colors of the series.\n *\n * @type {String[]}\n * @protected\n */\n Series.prototype._colors = null;\n\n /**\n * The fill mode of the series.\n *\n * @type {Object}\n * @protected\n */\n Series.prototype._fill = false;\n\n /**\n * The label of the series.\n *\n * @type {String}\n * @protected\n */\n Series.prototype._label = null;\n\n /**\n * The labels for the values of the series.\n *\n * @type {String[]}\n * @protected\n */\n Series.prototype._labels = null;\n\n /**\n * Whether the line of the serie should be smooth or not.\n *\n * @type {Bool}\n * @protected\n */\n Series.prototype._smooth = false;\n\n /**\n * The type of the series.\n *\n * @type {String}\n * @protected\n */\n Series.prototype._type = Series.prototype.TYPE_DEFAULT;\n\n /**\n * The values in the series.\n *\n * @type {Number[]}\n * @protected\n */\n Series.prototype._values = null;\n\n /**\n * The index of the X axis.\n *\n * @type {Number[]}\n * @protected\n */\n Series.prototype._xaxis = null;\n\n /**\n * The index of the Y axis.\n *\n * @type {Number[]}\n * @protected\n */\n Series.prototype._yaxis = null;\n\n /**\n * Create a new instance of a series from serialised data.\n *\n * @static\n * @method create\n * @param {Object} obj The data of the series.\n * @return {module:core/chart_series}\n */\n Series.prototype.create = function(obj) {\n var s = new Series(obj.label, obj.values);\n s.setType(obj.type);\n s.setXAxis(obj.axes.x);\n s.setYAxis(obj.axes.y);\n s.setLabels(obj.labels);\n\n // Colors are exported as an array with 1, or n values.\n if (obj.colors && obj.colors.length > 1) {\n s.setColors(obj.colors);\n } else {\n s.setColor(obj.colors[0]);\n }\n\n s.setFill(obj.fill);\n s.setSmooth(obj.smooth);\n return s;\n };\n\n /**\n * Get the col