@difftim/excelize
Version:
Excel Workbook Manager - Read and Write xlsx and csv Files.
75 lines (64 loc) • 1.51 kB
JavaScript
const BaseXform = require('../base-xform');
// const AGraphicDataXform = require('./c-chart-xform');
const CTitle = require('./title/c-title-xform');
const CPlotArea = require('./data/c-plotArea-xform');
class CChartXform extends BaseXform {
constructor() {
super();
this.map = {
'c:title': new CTitle(),
'c:plotArea': new CPlotArea(),
};
}
get tag() {
return 'c:chart';
}
render(xmlStream, model) {
xmlStream.openNode(this.tag);
this.map['c:plotArea'].render(xmlStream, model);
this.map['c:title'].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:
this.model = {
title: (this.map['c:title'].model || {}).title,
content: this.map['c:plotArea'].model || [],
};
return false;
default:
return true;
}
}
}
module.exports = CChartXform;