@difftim/excelize
Version:
Excel Workbook Manager - Read and Write xlsx and csv Files.
79 lines (68 loc) • 1.64 kB
JavaScript
const BaseXform = require('../../base-xform');
const CSerXform = require('./c-ser-xform');
const CBarDir = require('./c-bar-dir-xform');
const CGrouping = require('./c-grouping-xform');
class CBarChart extends BaseXform {
constructor() {
super();
this.map = {
'c:ser': new CSerXform(),
'c:barDir': new CBarDir(),
'c:grouping': new CGrouping(),
};
}
get tag() {
return 'c:barChart';
}
render(xmlStream, model) {
xmlStream.openNode(this.tag);
this.map['c:ser'].render(xmlStream, model);
this.map['c:barDir'].render(xmlStream, model);
this.map['c:grouping'].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 = {
data: this.map['c:ser'].model,
...this.map['c:barDir'].model,
...this.map['c:grouping'].model,
};
// this.model = this.map['c:barDir'].model;
return false;
default:
return true;
}
}
}
module.exports = CBarChart;