/
var
/
www
/
html
/
lgpd
/
lib
/
amd
/
build
/
Upload File
HOME
{"version":3,"sources":["../src/chart_series.js"],"names":["define","Series","label","values","Error","length","_colors","_label","_values","prototype","TYPE_DEFAULT","TYPE_LINE","_labels","_smooth","_type","_xaxis","_yaxis","create","obj","s","setType","type","setXAxis","axes","x","setYAxis","y","setLabels","labels","colors","setColors","setColor","setSmooth","smooth","getColor","getColors","getCount","getLabel","getLabels","getSmooth","getType","getValues","getXAxis","getYAxis","hasColoredValues","color","_validateLabels","index"],"mappings":"yQAuBAA,OAAM,qBAAC,EAAD,CAAK,UAAW,CAUlB,QAASC,CAAAA,CAAT,CAAgBC,CAAhB,CAAuBC,CAAvB,CAA+B,CAC3B,GAAqB,QAAjB,QAAOD,CAAAA,CAAX,CAA+B,CAC3B,KAAM,IAAIE,CAAAA,KAAJ,CAAU,2BAAV,CAET,CAHD,IAGO,IAAsB,QAAlB,WAAOD,CAAP,CAAJ,CAAgC,CACnC,KAAM,IAAIC,CAAAA,KAAJ,CAAU,uCAAV,CAET,CAHM,IAGA,IAAoB,CAAhB,CAAAD,CAAM,CAACE,MAAX,CAAuB,CAC1B,KAAM,IAAID,CAAAA,KAAJ,CAAU,qCAAV,CACT,CAED,KAAKE,OAAL,CAAe,EAAf,CACA,KAAKC,MAAL,CAAcL,CAAd,CACA,KAAKM,OAAL,CAAeL,CAClB,CAQDF,CAAM,CAACQ,SAAP,CAAiBC,YAAjB,CAAgC,IAAhC,CAQAT,CAAM,CAACQ,SAAP,CAAiBE,SAAjB,CAA6B,MAA7B,CAQAV,CAAM,CAACQ,SAAP,CAAiBH,OAAjB,CAA2B,IAA3B,CAQAL,CAAM,CAACQ,SAAP,CAAiBF,MAAjB,CAA0B,IAA1B,CAQCN,CAAM,CAACQ,SAAP,CAAiBG,OAAjB,CAA2B,IAA3B,CAQDX,CAAM,CAACQ,SAAP,CAAiBI,OAAjB,IAQAZ,CAAM,CAACQ,SAAP,CAAiBK,KAAjB,CAAyBb,CAAM,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B,EACAA,CAAM,CAAqB,WAAlB,QAAOA,CAAAA,CAAP,CAAgC,IAAhC,CAAuCA,CAAhD,CACA,KAAKhB,OAAL,CAAegB,CAClB,CAJD,CAaA3B,CAAM,CAACQ,SAAP,CAAiBuB,SAAjB,CAA6B,SAASC,CAAT,CAAiB,CAC1CA,CAAM,CAAqB,WAAlB,QAAOA,CAAAA,CAAP,CAAgC,IAAhC,CAAuCA,CAAhD,CACA,KAAKpB,OAAL,CAAeoB,CAClB,CAHD,CAUAhC,CAAM,CAACQ,SAAP,CAAiBW,OAAjB,CAA2B,SAASC,CAAT,CAAe,CACtC,GAAIA,CAAI,EAAI,KAAKX,YAAb,EAA6BW,CAAI,EAAI,KAAKV,SAA9C,CAAyD,CACrD,KAAM,IAAIP,CAAAA,KAAJ,CAAU,qBAAV,CACT,CACD,KAAKU,KAAL,CAAaO,CAAI,EAAI,IACxB,CALD,CAYApB,CAAM,CAACQ,SAAP,CAAiBa,QAAjB,CAA4B,SAASyB,CAAT,CAAgB,CACxC,KAAKhC,MAAL,CAAcgC,CAAK,EAAI,IAC1B,CAFD,CAUA9C,CAAM,CAACQ,SAAP,CAAiBgB,QAAjB,CAA4B,SAASsB,CAAT,CAAgB,CACxC,KAAK/B,MAAL,CAAc+B,CAAK,EAAI,IAC1B,CAFD,CAUA9C,CAAM,CAACQ,SAAP,CAAiBqC,eAAjB,CAAmC,SAASlB,CAAT,CAAiB,CAChD,GAAIA,CAAM,EAAoB,CAAhB,CAAAA,CAAM,CAACvB,MAAjB,EAA+BuB,CAAM,CAACvB,MAAP,EAAiB,KAAK+B,QAAL,EAApD,CAAqE,CACjE,KAAM,IAAIhC,CAAAA,KAAJ,CAAU,yCAAV,CACT,CACJ,CAJD,CAMA,MAAOH,CAAAA,CAEV,CAhUK,CAAN","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 * @package core\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 * @alias module:core/chart_series\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 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.setSmooth(obj.smooth);\n return s;\n };\n\n /**\n * Get the color.\n *\n * @return {String}\n */\n Series.prototype.getColor = function() {\n return this._colors[0] || null;\n };\n\n /**\n * Get the colors for each value in the series.\n *\n * @return {String[]}\n */\n Series.prototype.getColors = function() {\n return this._colors;\n };\n\n /**\n * Get the number of values in the series.\n *\n * @return {Number}\n */\n Series.prototype.getCount = function() {\n return this._values.length;\n };\n\n /**\n * Get the series label.\n *\n * @return {String}\n */\n Series.prototype.getLabel = function() {\n return this._label;\n };\n\n /**\n * Get labels for the values of the series.\n *\n * @return {String[]}\n */\n Series.prototype.getLabels = function() {\n return this._labels;\n };\n\n /**\n * Get whether the line of the serie should be smooth or not.\n *\n * @returns {Bool}\n */\n Series.prototype.getSmooth = function() {\n return this._smooth;\n };\n\n /**\n * Get the series type.\n *\n * @return {String}\n */\n Series.prototype.getType = function() {\n return this._type;\n };\n\n /**\n * Get the series values.\n *\n * @return {Number[]}\n */\n Series.prototype.getValues = function() {\n return this._values;\n };\n\n /**\n * Get the index of the X axis.\n *\n * @return {Number}\n */\n Series.prototype.getXAxis = function() {\n return this._xaxis;\n };\n\n /**\n * Get the index of the Y axis.\n *\n * @return {Number}\n */\n Series.prototype.getYAxis = function() {\n return this._yaxis;\n };\n\n /**\n * Whether there is a color per value.\n *\n * @return {Bool}\n */\n Series.prototype.hasColoredValues = function() {\n return this._colors.length == this.getCount();\n };\n\n /**\n * Set the series color.\n *\n * @param {String} color A CSS-compatible color.\n */\n Series.prototype.setColor = function(color) {\n this._colors = [color];\n };\n\n /**\n * Set a color for each value in the series.\n *\n * @param {String[]} colors CSS-compatible colors.\n */\n Series.prototype.setColors = function(colors) {\n if (colors && colors.length != this.getCount()) {\n throw new Error('When setting multiple colors there must be one per value.');\n }\n this._colors = colors || [];\n };\n\n /**\n * Set the labels for the values of the series.\n *\n * @param {String[]} labels the labels of the series values.\n */\n Series.prototype.setLabels = function(labels) {\n this._validateLabels(labels);\n labels = typeof labels === 'undefined' ? null : labels;\n this._labels = labels;\n };\n\n /**\n * Set Whether the line of the serie should be smooth or not.\n *\n * Only applicable for line chart or a line series, if null it assumes the chart default (not smooth).\n *\n * @param {Bool} smooth True if the lines should be smooth, false for tensioned lines.\n */\n Series.prototype.setSmooth = function(smooth) {\n smooth = typeof smooth === 'undefined' ? null : smooth;\n this._smooth = smooth;\n };\n\n /**\n * Set the type of the series.\n *\n * @param {String} type A type constant value.\n */\n Series.prototype.setType = function(type) {\n if (type != this.TYPE_DEFAULT && type != this.TYPE_LINE) {\n throw new Error('Invalid serie type.');\n }\n this._type = type || null;\n };\n\n /**\n * Set the index of the X axis.\n *\n * @param {Number} index The index.\n */\n Series.prototype.setXAxis = function(index) {\n this._xaxis = index || null;\n };\n\n\n /**\n * Set the index of the Y axis.\n *\n * @param {Number} index The index.\n */\n Series.prototype.setYAxis = function(index) {\n this._yaxis = index || null;\n };\n\n /**\n * Validate series labels.\n *\n * @protected\n * @param {String[]} labels The labels of the serie.\n */\n Series.prototype._validateLabels = function(labels) {\n if (labels && labels.length > 0 && labels.length != this.getCount()) {\n throw new Error('Series labels must match series values.');\n }\n };\n\n return Series;\n\n});\n"],"file":"chart_series.min.js"}