HEX
Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/8.0.30
System: Linux multiplicar 3.10.0-1160.102.1.el7.x86_64 #1 SMP Tue Oct 17 15:42:21 UTC 2023 x86_64
User: root (0)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /var/www/html/formacion.bdp.com.py-bk/lib/amd/build/chart_output_chartjs.min.js.map
{"version":3,"file":"chart_output_chartjs.min.js","sources":["../src/chart_output_chartjs.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 output for chart.js.\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_output_chartjs\n */\ndefine([\n    'jquery',\n    'core/chartjs',\n    'core/chart_axis',\n    'core/chart_bar',\n    'core/chart_output_base',\n    'core/chart_line',\n    'core/chart_pie',\n    'core/chart_series'\n], function($, Chartjs, Axis, Bar, Base, Line, Pie, Series) {\n\n    /**\n     * Makes an axis ID.\n     *\n     * @param {String} xy Accepts 'x' and 'y'.\n     * @param {Number} index The axis index.\n     * @return {String}\n     */\n    var makeAxisId = function(xy, index) {\n        return 'axis-' + xy + '-' + index;\n    };\n\n    /**\n     * Chart output for Chart.js.\n     *\n     * @class\n     * @extends {module:core/chart_output_base}\n     */\n    function Output() {\n        Base.prototype.constructor.apply(this, arguments);\n\n        // Make sure that we've got a canvas tag.\n        this._canvas = this._node;\n        if (this._canvas.prop('tagName') != 'CANVAS') {\n            this._canvas = $('<canvas>');\n            this._node.append(this._canvas);\n        }\n\n        this._build();\n    }\n    Output.prototype = Object.create(Base.prototype);\n\n    /**\n     * Reference to the chart config object.\n     *\n     * @type {Object}\n     * @protected\n     */\n    Output.prototype._config = null;\n\n    /**\n     * Reference to the instance of chart.js.\n     *\n     * @type {Object}\n     * @protected\n     */\n    Output.prototype._chartjs = null;\n\n    /**\n     * Reference to the canvas node.\n     *\n     * @type {Jquery}\n     * @protected\n     */\n    Output.prototype._canvas = null;\n\n    /**\n     * Builds the config and the chart.\n     *\n     * @protected\n     */\n    Output.prototype._build = function() {\n        this._config = this._makeConfig();\n        this._chartjs = new Chartjs(this._canvas[0], this._config);\n    };\n\n    /**\n     * Clean data.\n     *\n     * @param {(String|String[])} data A single string or an array of strings.\n     * @returns {(String|String[])}\n     * @protected\n     */\n    Output.prototype._cleanData = function(data) {\n        if (data instanceof Array) {\n            return data.map(function(value) {\n                return $('<span>').html(value).text();\n            });\n        } else {\n            return $('<span>').html(data).text();\n        }\n    };\n\n    /**\n     * Get the chart type and handles the Chart.js specific chart types.\n     *\n     * By default returns the current chart TYPE value. Also does the handling of specific chart types, for example\n     * check if the bar chart should be horizontal and the pie chart should be displayed as a doughnut.\n     *\n     * @method getChartType\n     * @returns {String} the chart type.\n     * @protected\n     */\n    Output.prototype._getChartType = function() {\n        var type = this._chart.getType();\n\n        // Bars can be displayed vertically and horizontally, defining horizontalBar type.\n        if (this._chart.getType() === Bar.prototype.TYPE && this._chart.getHorizontal() === true) {\n            type = 'horizontalBar';\n        } else if (this._chart.getType() === Pie.prototype.TYPE && this._chart.getDoughnut() === true) {\n            // Pie chart can be displayed as doughnut.\n            type = 'doughnut';\n        }\n\n        return type;\n    };\n\n    /**\n     * Make the axis config.\n     *\n     * @protected\n     * @param {module:core/chart_axis} axis The axis.\n     * @param {String} xy Accepts 'x' or 'y'.\n     * @param {Number} index The axis index.\n     * @return {Object} The axis config.\n     */\n    Output.prototype._makeAxisConfig = function(axis, xy, index) {\n        var scaleData = {\n            id: makeAxisId(xy, index)\n        };\n\n        if (axis.getPosition() !== Axis.prototype.POS_DEFAULT) {\n            scaleData.position = axis.getPosition();\n        }\n\n        if (axis.getLabel() !== null) {\n            scaleData.scaleLabel = {\n                display: true,\n                labelString: this._cleanData(axis.getLabel())\n            };\n        }\n\n        if (axis.getStepSize() !== null) {\n            scaleData.ticks = scaleData.ticks || {};\n            scaleData.ticks.stepSize = axis.getStepSize();\n        }\n\n        if (axis.getMax() !== null) {\n            scaleData.ticks = scaleData.ticks || {};\n            scaleData.ticks.max = axis.getMax();\n        }\n\n        if (axis.getMin() !== null) {\n            scaleData.ticks = scaleData.ticks || {};\n            scaleData.ticks.min = axis.getMin();\n        }\n\n        return scaleData;\n    };\n\n    /**\n     * Make the config config.\n     *\n     * @protected\n     * @return {Object} The axis config.\n     */\n    Output.prototype._makeConfig = function() {\n        var config = {\n            type: this._getChartType(),\n            data: {\n                labels: this._cleanData(this._chart.getLabels()),\n                datasets: this._makeDatasetsConfig()\n            },\n            options: {\n                title: {\n                    display: this._chart.getTitle() !== null,\n                    text: this._cleanData(this._chart.getTitle())\n                }\n            }\n        };\n        var legendOptions = this._chart.getLegendOptions();\n        if (legendOptions) {\n            config.options.legend = legendOptions;\n        }\n\n\n        this._chart.getXAxes().forEach(function(axis, i) {\n            var axisLabels = axis.getLabels();\n\n            config.options.scales = config.options.scales || {};\n            config.options.scales.xAxes = config.options.scales.xAxes || [];\n            config.options.scales.xAxes[i] = this._makeAxisConfig(axis, 'x', i);\n\n            if (axisLabels !== null) {\n                config.options.scales.xAxes[i].ticks.callback = function(value, index) {\n                    return axisLabels[index] || '';\n                };\n            }\n            config.options.scales.xAxes[i].stacked = this._isStacked();\n        }.bind(this));\n\n        this._chart.getYAxes().forEach(function(axis, i) {\n            var axisLabels = axis.getLabels();\n\n            config.options.scales = config.options.scales || {};\n            config.options.scales.yAxes = config.options.scales.yAxes || [];\n            config.options.scales.yAxes[i] = this._makeAxisConfig(axis, 'y', i);\n\n            if (axisLabels !== null) {\n                config.options.scales.yAxes[i].ticks.callback = function(value) {\n                    return axisLabels[parseInt(value, 10)] || '';\n                };\n            }\n            config.options.scales.yAxes[i].stacked = this._isStacked();\n        }.bind(this));\n\n        config.options.tooltips = {\n            callbacks: {\n                label: this._makeTooltip.bind(this)\n            }\n        };\n\n        return config;\n    };\n\n    /**\n     * Get the datasets configurations.\n     *\n     * @protected\n     * @return {Object[]}\n     */\n    Output.prototype._makeDatasetsConfig = function() {\n        var sets = this._chart.getSeries().map(function(series) {\n            var colors = series.hasColoredValues() ? series.getColors() : series.getColor();\n            var dataset = {\n                label: this._cleanData(series.getLabel()),\n                data: series.getValues(),\n                type: series.getType(),\n                fill: series.getFill(),\n                backgroundColor: colors,\n                // Pie charts look better without borders.\n                borderColor: this._chart.getType() == Pie.prototype.TYPE ? '#fff' : colors,\n                lineTension: this._isSmooth(series) ? 0.3 : 0\n            };\n\n            if (series.getXAxis() !== null) {\n                dataset.xAxisID = makeAxisId('x', series.getXAxis());\n            }\n            if (series.getYAxis() !== null) {\n                dataset.yAxisID = makeAxisId('y', series.getYAxis());\n            }\n\n            return dataset;\n        }.bind(this));\n        return sets;\n    };\n\n    /**\n     * Get the chart data, add labels and rebuild the tooltip.\n     *\n     * @param {Object[]} tooltipItem The tooltip item data.\n     * @param {Object[]} data The chart data.\n     * @returns {String}\n     * @protected\n     */\n    Output.prototype._makeTooltip = function(tooltipItem, data) {\n\n        // Get series and chart data to rebuild the tooltip and add labels.\n        var series = this._chart.getSeries()[tooltipItem.datasetIndex];\n        var serieLabel = series.getLabel();\n        var serieLabels = series.getLabels();\n        var chartData = data.datasets[tooltipItem.datasetIndex].data;\n        var tooltipData = chartData[tooltipItem.index];\n\n        // Build default tooltip.\n        var tooltip = [];\n\n        // Pie and doughnut charts does not have axis.\n        if (tooltipItem.xLabel == '' && tooltipItem.yLabel == '') {\n            var chartLabels = this._cleanData(this._chart.getLabels());\n            tooltip.push(chartLabels[tooltipItem.index]);\n        }\n\n        // Add series labels to the tooltip if any.\n        if (serieLabels !== null) {\n            tooltip.push(this._cleanData(serieLabels[tooltipItem.index]));\n        } else {\n            tooltip.push(this._cleanData(serieLabel) + ': ' + tooltipData);\n        }\n\n        return tooltip;\n    };\n\n    /**\n     * Verify if the chart line is smooth or not.\n     *\n     * @protected\n     * @param {module:core/chart_series} series The series.\n     * @returns {Bool}\n     */\n    Output.prototype._isSmooth = function(series) {\n        var smooth = false;\n        if (this._chart.getType() === Line.prototype.TYPE) {\n            smooth = series.getSmooth();\n            if (smooth === null) {\n                smooth = this._chart.getSmooth();\n            }\n        } else if (series.getType() === Series.prototype.TYPE_LINE) {\n            smooth = series.getSmooth();\n        }\n\n        return smooth;\n    };\n\n    /**\n     * Verify if the bar chart is stacked or not.\n     *\n     * @protected\n     * @returns {Bool}\n     */\n    Output.prototype._isStacked = function() {\n        var stacked = false;\n\n        // Stacking is (currently) only supported for bar charts.\n        if (this._chart.getType() === Bar.prototype.TYPE) {\n            stacked = this._chart.getStacked();\n        }\n\n        return stacked;\n    };\n\n    /** @override */\n    Output.prototype.update = function() {\n        $.extend(true, this._config, this._makeConfig());\n        this._chartjs.update();\n    };\n\n    return Output;\n\n});\n"],"names":["define","$","Chartjs","Axis","Bar","Base","Line","Pie","Series","makeAxisId","xy","index","Output","prototype","constructor","apply","this","arguments","_canvas","_node","prop","append","_build","Object","create","_config","_chartjs","_makeConfig","_cleanData","data","Array","map","value","html","text","_getChartType","type","_chart","getType","TYPE","getHorizontal","getDoughnut","_makeAxisConfig","axis","scaleData","id","getPosition","POS_DEFAULT","position","getLabel","scaleLabel","display","labelString","getStepSize","ticks","stepSize","getMax","max","getMin","min","config","labels","getLabels","datasets","_makeDatasetsConfig","options","title","getTitle","legendOptions","getLegendOptions","legend","getXAxes","forEach","i","axisLabels","scales","xAxes","callback","stacked","_isStacked","bind","getYAxes","yAxes","parseInt","tooltips","callbacks","label","_makeTooltip","getSeries","series","colors","hasColoredValues","getColors","getColor","dataset","getValues","fill","getFill","backgroundColor","borderColor","lineTension","_isSmooth","getXAxis","xAxisID","getYAxis","yAxisID","tooltipItem","datasetIndex","serieLabel","serieLabels","tooltipData","tooltip","xLabel","yLabel","chartLabels","push","smooth","getSmooth","TYPE_LINE","getStacked","update","extend"],"mappings":";;;;;;;AAsBAA,mCAAO,CACH,SACA,eACA,kBACA,iBACA,yBACA,kBACA,iBACA,sBACD,SAASC,EAAGC,QAASC,KAAMC,IAAKC,KAAMC,KAAMC,IAAKC,YAS5CC,WAAa,SAASC,GAAIC,aACnB,QAAUD,GAAK,IAAMC,gBASvBC,SACLP,KAAKQ,UAAUC,YAAYC,MAAMC,KAAMC,gBAGlCC,QAAUF,KAAKG,MACgB,UAAhCH,KAAKE,QAAQE,KAAK,kBACbF,QAAUjB,EAAE,iBACZkB,MAAME,OAAOL,KAAKE,eAGtBI,gBAETV,OAAOC,UAAYU,OAAOC,OAAOnB,KAAKQ,WAQtCD,OAAOC,UAAUY,QAAU,KAQ3Bb,OAAOC,UAAUa,SAAW,KAQ5Bd,OAAOC,UAAUK,QAAU,KAO3BN,OAAOC,UAAUS,OAAS,gBACjBG,QAAUT,KAAKW,mBACfD,SAAW,IAAIxB,QAAQc,KAAKE,QAAQ,GAAIF,KAAKS,UAUtDb,OAAOC,UAAUe,WAAa,SAASC,aAC/BA,gBAAgBC,MACTD,KAAKE,KAAI,SAASC,cACd/B,EAAE,UAAUgC,KAAKD,OAAOE,UAG5BjC,EAAE,UAAUgC,KAAKJ,MAAMK,QActCtB,OAAOC,UAAUsB,cAAgB,eACzBC,KAAOpB,KAAKqB,OAAOC,iBAGnBtB,KAAKqB,OAAOC,YAAclC,IAAIS,UAAU0B,OAAwC,IAAhCvB,KAAKqB,OAAOG,gBAC5DJ,KAAO,gBACApB,KAAKqB,OAAOC,YAAc/B,IAAIM,UAAU0B,OAAsC,IAA9BvB,KAAKqB,OAAOI,gBAEnEL,KAAO,YAGJA,MAYXxB,OAAOC,UAAU6B,gBAAkB,SAASC,KA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