Autoría | Ultima modificación | Ver Log |
{"version":3,"file":"chart_output_htmltable.min.js","sources":["../src/chart_output_htmltable.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 HTML table.\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_htmlt
able\n */\ndefine([\n 'jquery',\n 'core/chart_output_base',\n], function($, Base) {\n\n /**\n * Render a chart as an HTML table.\n *\n * @class\n * @extends {module:core/chart_output_base}\n */\n function Output() {\n Base.prototype.constructor.apply(this, arguments);\n this._build();\n }\n Output.prototype = Object.create(Base.prototype);\n\n /**\n * Attach the table to the document.\n *\n * @protected\n */\n Output.prototype._build = function() {\n this._node.empty();\n this._node.append(this._makeTable());\n };\n\n /**\n * Builds the table node.\n *\n * @protected\n * @return {Jquery}\n */\n Output.prototype._makeTable = function() {\n var tbl = $('<table>'),\n c = this._chart,\n node,\n value,\n labels = c.getLabels(),\n hasLabel = labels.length > 0,\n series = c.getSeries(),\n seriesLabels,\n ro
wCount = series[0].getCount();\n\n // Identify the table.\n tbl.addClass('chart-output-htmltable generaltable');\n\n // Set the caption.\n if (c.getTitle() !== null) {\n tbl.append($('<caption>').text(c.getTitle()));\n }\n\n // Write the column headers.\n node = $('<tr>');\n if (hasLabel) {\n node.append($('<td>'));\n }\n series.forEach(function(serie) {\n node.append(\n $('<th>')\n .text(serie.getLabel())\n .attr('scope', 'col')\n );\n });\n tbl.append(node);\n\n // Write rows.\n for (var rowId = 0; rowId < rowCount; rowId++) {\n node = $('<tr>');\n if (labels.length > 0) {\n node.append(\n $('<th>')\n .text(labels[rowId])\n .attr('scope', 'row')\n );\n }\n for (var serieId = 0; serieId < series
.length; serieId++) {\n value = series[serieId].getValues()[rowId];\n seriesLabels = series[serieId].getLabels();\n if (seriesLabels !== null) {\n value = series[serieId].getLabels()[rowId];\n }\n node.append($('<td>').text(value));\n }\n tbl.append(node);\n }\n\n return tbl;\n };\n\n /** @override */\n Output.prototype.update = function() {\n this._build();\n };\n\n return Output;\n\n});\n"],"names":["define","$","Base","Output","prototype","constructor","apply","this","arguments","_build","Object","create","_node","empty","append","_makeTable","node","value","tbl","c","_chart","labels","getLabels","hasLabel","length","series","getSeries","rowCount","getCount","addClass","getTitle","text","forEach","serie","getLabel","attr","rowId","serieId","getValues","update"],"mappings":";;;;;;;AAsBAA,qCAAO,CACH,SACA,2BACD,SAASC,EAAGC,eAQFC,SACLD,KAAKE,UAAUC,YAAYC,MAAMC,
KAAMC,gBAClCC,gBAETN,OAAOC,UAAYM,OAAOC,OAAOT,KAAKE,WAOtCD,OAAOC,UAAUK,OAAS,gBACjBG,MAAMC,aACND,MAAME,OAAOP,KAAKQ,eAS3BZ,OAAOC,UAAUW,WAAa,eAGtBC,KACAC,MAHAC,IAAMjB,EAAE,WACRkB,EAAIZ,KAAKa,OAGTC,OAASF,EAAEG,YACXC,SAAWF,OAAOG,OAAS,EAC3BC,OAASN,EAAEO,YAEXC,SAAWF,OAAO,GAAGG,WAGzBV,IAAIW,SAAS,uCAGQ,OAAjBV,EAAEW,YACFZ,IAAIJ,OAAOb,EAAE,aAAa8B,KAAKZ,EAAEW,aAIrCd,KAAOf,EAAE,QACLsB,UACAP,KAAKF,OAAOb,EAAE,SAElBwB,OAAOO,SAAQ,SAASC,OACpBjB,KAAKF,OACDb,EAAE,QACD8B,KAAKE,MAAMC,YACXC,KAAK,QAAS,WAGvBjB,IAAIJ,OAAOE,UAGN,IAAIoB,MAAQ,EAAGA,MAAQT,SAAUS,QAAS,CAC3CpB,KAAOf,EAAE,QACLoB,OAAOG,OAAS,GAChBR,KAAKF,OACDb,EAAE,QACD8B,KAAKV,OAAOe,QACZD,KAAK,QAAS,YAGlB,IAAIE,QAAU,EAAGA,QAAUZ,OAAOD,OAAQa,UAC3CpB,MAAQQ,OAAOY,SAASC,YAAYF,OAEf,OADNX,OAAOY,SAASf,cAE3BL,MAAQQ,OAAOY,SAASf,YAAYc,QAExCpB,KAAKF,OAAOb,EAAE,QAAQ8B,KAAKd,QAE/BC,IAAIJ,OAAOE,aAGRE,KAIXf,OAAOC,UAAUmC,OAAS,gBACjB9B,UAGFN"}