UNPKG

@difftim/excelize

Version:

Excel Workbook Manager - Read and Write xlsx and csv Files.

104 lines (103 loc) 3.03 kB
const BaseXform = require('../../base-xform'); const CLineChart = require('./line-chart-xform'); const CBarChart = require('./bar-chart-xform'); const CPieChart = require('./pie-chart-xform'); const CRadarChart = require('./radar-chart-xform'); const CAreaChart = require('./area-chart-xform'); const CCatAx = require('./cat-title-xform'); const CValAx = require('./val-title-xform'); class CPlotArea extends BaseXform { constructor() { super(); this.map = { 'c:barChart': new CBarChart(), 'c:lineChart': new CLineChart(), 'c:pieChart': new CPieChart(), 'c:radarChart': new CRadarChart(), 'c:areaChart': new CAreaChart(), 'c:catAx': new CCatAx(), 'c:valAx': new CValAx() }; } get tag() { return 'c:plotArea'; } render(xmlStream, model) { xmlStream.openNode(this.tag); this.map['c:barChart'].render(xmlStream, model); this.map['c:lineChart'].render(xmlStream, model); this.map['c:pieChart'].render(xmlStream, model); this.map['c:radarChart'].render(xmlStream, model); this.map['c:areaChart'].render(xmlStream, model); this.map['c:catAx'].render(xmlStream, model); this.map['c:valAx'].render(xmlStream, model); xmlStream.closeNode(); } parseOpen(node) { if (this.parser) { this.parser.parseOpen(node); return true; } switch (node.name) { case this.tag: this.reset(); break; default: this.parser = this.map[node.name]; if (this.parser) { this.parser.parseOpen(node); } break; } return true; } parseText(text) { if (this.parser) { this.parser.parseText(text); } } parseClose(name) { if (this.parser) { if (!this.parser.parseClose(name)) { this.parser = undefined; } return true; } switch (name) { case this.tag: { const _mode = []; Object.keys(this.map || {}).forEach(key => { // 组合图 可能各种图表共存 if (this.map[key].model && key.includes('Chart')) { let _key = key ? key.split(':')[1] : key; if (key === 'c:barChart') { const type = this.map[key].model.type || 'c:barChart'; const groupType = this.map[key].model.groupType || ''; _key = `${groupType}${type.split(':')[1]}`; _mode.push({ type: _key, data: this.map[key].model.data }); } else { _mode.push({ type: _key, data: this.map[key].model }); } } }); this.model = { range: _mode, ...(this.map['c:catAx'].model || {}), ...(this.map['c:valAx'].model || {}) }; return false; } default: return true; } } } module.exports = CPlotArea; //# sourceMappingURL=c-plotArea-xform.js.map