pptx-templates 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI-INSTRUCTOR.md +2253 -0
- package/CHANGELOG.md +56 -0
- package/LICENSE +23 -0
- package/README.md +84 -2
- package/dist/automizer.d.ts +224 -0
- package/dist/automizer.js +704 -0
- package/dist/automizer.js.map +1 -0
- package/dist/classes/content-type-registry.d.ts +46 -0
- package/dist/classes/content-type-registry.js +170 -0
- package/dist/classes/content-type-registry.js.map +1 -0
- package/dist/classes/element-importer.d.ts +49 -0
- package/dist/classes/element-importer.js +254 -0
- package/dist/classes/element-importer.js.map +1 -0
- package/dist/classes/has-shapes.d.ts +286 -0
- package/dist/classes/has-shapes.js +385 -0
- package/dist/classes/has-shapes.js.map +1 -0
- package/dist/classes/layout.d.ts +42 -0
- package/dist/classes/layout.js +113 -0
- package/dist/classes/layout.js.map +1 -0
- package/dist/classes/master.d.ts +45 -0
- package/dist/classes/master.js +146 -0
- package/dist/classes/master.js.map +1 -0
- package/dist/classes/placeholder-normalizer.d.ts +42 -0
- package/dist/classes/placeholder-normalizer.js +136 -0
- package/dist/classes/placeholder-normalizer.js.map +1 -0
- package/dist/classes/related-content-copier.d.ts +18 -0
- package/dist/classes/related-content-copier.js +114 -0
- package/dist/classes/related-content-copier.js.map +1 -0
- package/dist/classes/shape.d.ts +62 -0
- package/dist/classes/shape.js +194 -0
- package/dist/classes/shape.js.map +1 -0
- package/dist/classes/slide-master-remover.d.ts +44 -0
- package/dist/classes/slide-master-remover.js +201 -0
- package/dist/classes/slide-master-remover.js.map +1 -0
- package/dist/classes/slide-notes-copier.d.ts +26 -0
- package/dist/classes/slide-notes-copier.js +76 -0
- package/dist/classes/slide-notes-copier.js.map +1 -0
- package/dist/classes/slide.d.ts +91 -0
- package/dist/classes/slide.js +286 -0
- package/dist/classes/slide.js.map +1 -0
- package/dist/classes/template.d.ts +137 -0
- package/dist/classes/template.js +311 -0
- package/dist/classes/template.js.map +1 -0
- package/dist/constants/constants.d.ts +11 -0
- package/dist/constants/constants.js +182 -0
- package/dist/constants/constants.js.map +1 -0
- package/dist/enums/chart-type.d.ts +11 -0
- package/dist/enums/chart-type.js +16 -0
- package/dist/enums/chart-type.js.map +1 -0
- package/dist/enums/content-type-map.d.ts +16 -0
- package/dist/enums/content-type-map.js +23 -0
- package/dist/enums/content-type-map.js.map +1 -0
- package/dist/enums/element-type.d.ts +14 -0
- package/dist/enums/element-type.js +20 -0
- package/dist/enums/element-type.js.map +1 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.js +100 -0
- package/dist/errors.js.map +1 -0
- package/dist/extensions/index.d.ts +5 -0
- package/dist/extensions/index.js +31 -0
- package/dist/extensions/index.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.d.ts +5 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.js +9 -0
- package/dist/extensions/pptxgenjs-compat/img-broken-png.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/index.d.ts +5 -0
- package/dist/extensions/pptxgenjs-compat/index.js +10 -0
- package/dist/extensions/pptxgenjs-compat/index.js.map +1 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.d.ts +14 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.js +139 -0
- package/dist/extensions/pptxgenjs-compat/svg-fallback.js.map +1 -0
- package/dist/extensions/run-merge/index.d.ts +13 -0
- package/dist/extensions/run-merge/index.js +89 -0
- package/dist/extensions/run-merge/index.js.map +1 -0
- package/dist/extensions/template-logic/commands.d.ts +22 -0
- package/dist/extensions/template-logic/commands.js +83 -0
- package/dist/extensions/template-logic/commands.js.map +1 -0
- package/dist/extensions/template-logic/expression.d.ts +61 -0
- package/dist/extensions/template-logic/expression.js +499 -0
- package/dist/extensions/template-logic/expression.js.map +1 -0
- package/dist/extensions/template-logic/images.d.ts +26 -0
- package/dist/extensions/template-logic/images.js +183 -0
- package/dist/extensions/template-logic/images.js.map +1 -0
- package/dist/extensions/template-logic/index.d.ts +14 -0
- package/dist/extensions/template-logic/index.js +64 -0
- package/dist/extensions/template-logic/index.js.map +1 -0
- package/dist/extensions/template-logic/list-commands.d.ts +9 -0
- package/dist/extensions/template-logic/list-commands.js +72 -0
- package/dist/extensions/template-logic/list-commands.js.map +1 -0
- package/dist/extensions/template-logic/renderer.d.ts +85 -0
- package/dist/extensions/template-logic/renderer.js +867 -0
- package/dist/extensions/template-logic/renderer.js.map +1 -0
- package/dist/extensions/template-logic/types.d.ts +62 -0
- package/dist/extensions/template-logic/types.js +3 -0
- package/dist/extensions/template-logic/types.js.map +1 -0
- package/dist/helper/archive/archive-fs.d.ts +45 -0
- package/dist/helper/archive/archive-fs.js +206 -0
- package/dist/helper/archive/archive-fs.js.map +1 -0
- package/dist/helper/archive/archive-jszip.d.ts +31 -0
- package/dist/helper/archive/archive-jszip.js +173 -0
- package/dist/helper/archive/archive-jszip.js.map +1 -0
- package/dist/helper/archive/archive.d.ts +27 -0
- package/dist/helper/archive/archive.js +78 -0
- package/dist/helper/archive/archive.js.map +1 -0
- package/dist/helper/cell-id-helper.d.ts +25 -0
- package/dist/helper/cell-id-helper.js +95 -0
- package/dist/helper/cell-id-helper.js.map +1 -0
- package/dist/helper/compute-src-rect.d.ts +9 -0
- package/dist/helper/compute-src-rect.js +52 -0
- package/dist/helper/compute-src-rect.js.map +1 -0
- package/dist/helper/content-tracker.d.ts +31 -0
- package/dist/helper/content-tracker.js +227 -0
- package/dist/helper/content-tracker.js.map +1 -0
- package/dist/helper/count-helper.d.ts +33 -0
- package/dist/helper/count-helper.js +140 -0
- package/dist/helper/count-helper.js.map +1 -0
- package/dist/helper/css-style-parser.d.ts +52 -0
- package/dist/helper/css-style-parser.js +246 -0
- package/dist/helper/css-style-parser.js.map +1 -0
- package/dist/helper/file-helper.d.ts +36 -0
- package/dist/helper/file-helper.js +150 -0
- package/dist/helper/file-helper.js.map +1 -0
- package/dist/helper/general-helper.d.ts +6 -0
- package/dist/helper/general-helper.js +34 -0
- package/dist/helper/general-helper.js.map +1 -0
- package/dist/helper/generate/generate-pptxgenjs.d.ts +37 -0
- package/dist/helper/generate/generate-pptxgenjs.js +134 -0
- package/dist/helper/generate/generate-pptxgenjs.js.map +1 -0
- package/dist/helper/html-to-multitext-helper.d.ts +84 -0
- package/dist/helper/html-to-multitext-helper.js +490 -0
- package/dist/helper/html-to-multitext-helper.js.map +1 -0
- package/dist/helper/hyperlink-processor.d.ts +54 -0
- package/dist/helper/hyperlink-processor.js +289 -0
- package/dist/helper/hyperlink-processor.js.map +1 -0
- package/dist/helper/image-dimensions.d.ts +21 -0
- package/dist/helper/image-dimensions.js +202 -0
- package/dist/helper/image-dimensions.js.map +1 -0
- package/dist/helper/jszip-helper.d.ts +21 -0
- package/dist/helper/jszip-helper.js +162 -0
- package/dist/helper/jszip-helper.js.map +1 -0
- package/dist/helper/layout-index.d.ts +55 -0
- package/dist/helper/layout-index.js +155 -0
- package/dist/helper/layout-index.js.map +1 -0
- package/dist/helper/logger.d.ts +53 -0
- package/dist/helper/logger.js +73 -0
- package/dist/helper/logger.js.map +1 -0
- package/dist/helper/media-deduplicator.d.ts +42 -0
- package/dist/helper/media-deduplicator.js +88 -0
- package/dist/helper/media-deduplicator.js.map +1 -0
- package/dist/helper/modify-background-helper.d.ts +19 -0
- package/dist/helper/modify-background-helper.js +59 -0
- package/dist/helper/modify-background-helper.js.map +1 -0
- package/dist/helper/modify-chart-helper.d.ts +159 -0
- package/dist/helper/modify-chart-helper.js +642 -0
- package/dist/helper/modify-chart-helper.js.map +1 -0
- package/dist/helper/modify-cleanup-helper.d.ts +69 -0
- package/dist/helper/modify-cleanup-helper.js +343 -0
- package/dist/helper/modify-cleanup-helper.js.map +1 -0
- package/dist/helper/modify-color-helper.d.ts +35 -0
- package/dist/helper/modify-color-helper.js +211 -0
- package/dist/helper/modify-color-helper.js.map +1 -0
- package/dist/helper/modify-helper.d.ts +23 -0
- package/dist/helper/modify-helper.js +61 -0
- package/dist/helper/modify-helper.js.map +1 -0
- package/dist/helper/modify-hyperlink-element.d.ts +9 -0
- package/dist/helper/modify-hyperlink-element.js +34 -0
- package/dist/helper/modify-hyperlink-element.js.map +1 -0
- package/dist/helper/modify-hyperlink-helper.d.ts +42 -0
- package/dist/helper/modify-hyperlink-helper.js +258 -0
- package/dist/helper/modify-hyperlink-helper.js.map +1 -0
- package/dist/helper/modify-image-helper.d.ts +23 -0
- package/dist/helper/modify-image-helper.js +157 -0
- package/dist/helper/modify-image-helper.js.map +1 -0
- package/dist/helper/modify-presentation-helper.d.ts +55 -0
- package/dist/helper/modify-presentation-helper.js +177 -0
- package/dist/helper/modify-presentation-helper.js.map +1 -0
- package/dist/helper/modify-shape-helper.d.ts +111 -0
- package/dist/helper/modify-shape-helper.js +340 -0
- package/dist/helper/modify-shape-helper.js.map +1 -0
- package/dist/helper/modify-table-helper.d.ts +11 -0
- package/dist/helper/modify-table-helper.js +100 -0
- package/dist/helper/modify-table-helper.js.map +1 -0
- package/dist/helper/modify-text-helper.d.ts +62 -0
- package/dist/helper/modify-text-helper.js +244 -0
- package/dist/helper/modify-text-helper.js.map +1 -0
- package/dist/helper/modify-xml-helper.d.ts +52 -0
- package/dist/helper/modify-xml-helper.js +305 -0
- package/dist/helper/modify-xml-helper.js.map +1 -0
- package/dist/helper/multitext-helper.d.ts +116 -0
- package/dist/helper/multitext-helper.js +462 -0
- package/dist/helper/multitext-helper.js.map +1 -0
- package/dist/helper/ppt-paths.d.ts +76 -0
- package/dist/helper/ppt-paths.js +116 -0
- package/dist/helper/ppt-paths.js.map +1 -0
- package/dist/helper/shape-type-detector.d.ts +34 -0
- package/dist/helper/shape-type-detector.js +99 -0
- package/dist/helper/shape-type-detector.js.map +1 -0
- package/dist/helper/text-replace-helper.d.ts +30 -0
- package/dist/helper/text-replace-helper.js +149 -0
- package/dist/helper/text-replace-helper.js.map +1 -0
- package/dist/helper/xml/lnLRTB.d.ts +1 -0
- package/dist/helper/xml/lnLRTB.js +62 -0
- package/dist/helper/xml/lnLRTB.js.map +1 -0
- package/dist/helper/xml/prstGeom.d.ts +1 -0
- package/dist/helper/xml/prstGeom.js +11 -0
- package/dist/helper/xml/prstGeom.js.map +1 -0
- package/dist/helper/xml-elements.d.ts +134 -0
- package/dist/helper/xml-elements.js +538 -0
- package/dist/helper/xml-elements.js.map +1 -0
- package/dist/helper/xml-helper.d.ts +120 -0
- package/dist/helper/xml-helper.js +495 -0
- package/dist/helper/xml-helper.js.map +1 -0
- package/dist/helper/xml-placeholder-helper.d.ts +92 -0
- package/dist/helper/xml-placeholder-helper.js +454 -0
- package/dist/helper/xml-placeholder-helper.js.map +1 -0
- package/dist/helper/xml-pretty-print.d.ts +17 -0
- package/dist/helper/xml-pretty-print.js +88 -0
- package/dist/helper/xml-pretty-print.js.map +1 -0
- package/dist/helper/xml-relationship-helper.d.ts +103 -0
- package/dist/helper/xml-relationship-helper.js +397 -0
- package/dist/helper/xml-relationship-helper.js.map +1 -0
- package/dist/helper/xml-slide-helper.d.ts +107 -0
- package/dist/helper/xml-slide-helper.js +676 -0
- package/dist/helper/xml-slide-helper.js.map +1 -0
- package/dist/helper/xml-template-helper.d.ts +42 -0
- package/dist/helper/xml-template-helper.js +252 -0
- package/dist/helper/xml-template-helper.js.map +1 -0
- package/dist/helper/xmldom-sax-patch.d.ts +18 -0
- package/dist/helper/xmldom-sax-patch.js +58 -0
- package/dist/helper/xmldom-sax-patch.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.js +177 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/iarchive.d.ts +43 -0
- package/dist/interfaces/iarchive.js +3 -0
- package/dist/interfaces/iarchive.js.map +1 -0
- package/dist/interfaces/ichart.d.ts +7 -0
- package/dist/interfaces/ichart.js +3 -0
- package/dist/interfaces/ichart.js.map +1 -0
- package/dist/interfaces/icounter.d.ts +7 -0
- package/dist/interfaces/icounter.js +3 -0
- package/dist/interfaces/icounter.js.map +1 -0
- package/dist/interfaces/igenerator.d.ts +4 -0
- package/dist/interfaces/igenerator.js +3 -0
- package/dist/interfaces/igenerator.js.map +1 -0
- package/dist/interfaces/iimage.d.ts +7 -0
- package/dist/interfaces/iimage.js +3 -0
- package/dist/interfaces/iimage.js.map +1 -0
- package/dist/interfaces/ilayout.d.ts +14 -0
- package/dist/interfaces/ilayout.js +3 -0
- package/dist/interfaces/ilayout.js.map +1 -0
- package/dist/interfaces/imaster.d.ts +15 -0
- package/dist/interfaces/imaster.js +3 -0
- package/dist/interfaces/imaster.js.map +1 -0
- package/dist/interfaces/imulti-text.d.ts +50 -0
- package/dist/interfaces/imulti-text.js +3 -0
- package/dist/interfaces/imulti-text.js.map +1 -0
- package/dist/interfaces/ipptxgenjs-slide.d.ts +40 -0
- package/dist/interfaces/ipptxgenjs-slide.js +3 -0
- package/dist/interfaces/ipptxgenjs-slide.js.map +1 -0
- package/dist/interfaces/ipresentation-props.d.ts +16 -0
- package/dist/interfaces/ipresentation-props.js +3 -0
- package/dist/interfaces/ipresentation-props.js.map +1 -0
- package/dist/interfaces/ishape-action.d.ts +18 -0
- package/dist/interfaces/ishape-action.js +3 -0
- package/dist/interfaces/ishape-action.js.map +1 -0
- package/dist/interfaces/ishape.d.ts +5 -0
- package/dist/interfaces/ishape.js +3 -0
- package/dist/interfaces/ishape.js.map +1 -0
- package/dist/interfaces/islide.d.ts +71 -0
- package/dist/interfaces/islide.js +3 -0
- package/dist/interfaces/islide.js.map +1 -0
- package/dist/interfaces/itemplate.d.ts +9 -0
- package/dist/interfaces/itemplate.js +3 -0
- package/dist/interfaces/itemplate.js.map +1 -0
- package/dist/interfaces/pres-template.d.ts +9 -0
- package/dist/interfaces/pres-template.js +3 -0
- package/dist/interfaces/pres-template.js.map +1 -0
- package/dist/interfaces/root-pres-template.d.ts +38 -0
- package/dist/interfaces/root-pres-template.js +3 -0
- package/dist/interfaces/root-pres-template.js.map +1 -0
- package/dist/modify/modify-chart.d.ts +74 -0
- package/dist/modify/modify-chart.js +753 -0
- package/dist/modify/modify-chart.js.map +1 -0
- package/dist/modify/modify-table.d.ts +64 -0
- package/dist/modify/modify-table.js +435 -0
- package/dist/modify/modify-table.js.map +1 -0
- package/dist/shapes/chart.d.ts +91 -0
- package/dist/shapes/chart.js +437 -0
- package/dist/shapes/chart.js.map +1 -0
- package/dist/shapes/diagram.d.ts +33 -0
- package/dist/shapes/diagram.js +167 -0
- package/dist/shapes/diagram.js.map +1 -0
- package/dist/shapes/generic.d.ts +27 -0
- package/dist/shapes/generic.js +118 -0
- package/dist/shapes/generic.js.map +1 -0
- package/dist/shapes/hyperlink.d.ts +27 -0
- package/dist/shapes/hyperlink.js +193 -0
- package/dist/shapes/hyperlink.js.map +1 -0
- package/dist/shapes/image.d.ts +47 -0
- package/dist/shapes/image.js +244 -0
- package/dist/shapes/image.js.map +1 -0
- package/dist/shapes/ole.d.ts +30 -0
- package/dist/shapes/ole.js +237 -0
- package/dist/shapes/ole.js.map +1 -0
- package/dist/types/chart-types.d.ts +115 -0
- package/dist/types/chart-types.js +3 -0
- package/dist/types/chart-types.js.map +1 -0
- package/dist/types/modify-types.d.ts +128 -0
- package/dist/types/modify-types.js +3 -0
- package/dist/types/modify-types.js.map +1 -0
- package/dist/types/shape-types.d.ts +40 -0
- package/dist/types/shape-types.js +3 -0
- package/dist/types/shape-types.js.map +1 -0
- package/dist/types/table-types.d.ts +38 -0
- package/dist/types/table-types.js +3 -0
- package/dist/types/table-types.js.map +1 -0
- package/dist/types/types.d.ts +317 -0
- package/dist/types/types.js +16 -0
- package/dist/types/types.js.map +1 -0
- package/dist/types/xml-types.d.ts +168 -0
- package/dist/types/xml-types.js +3 -0
- package/dist/types/xml-types.js.map +1 -0
- package/package.json +92 -4
|
@@ -0,0 +1,753 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ModifyChart = void 0;
|
|
7
|
+
const xml_helper_1 = require("../helper/xml-helper");
|
|
8
|
+
const cell_id_helper_1 = __importDefault(require("../helper/cell-id-helper"));
|
|
9
|
+
const modify_xml_helper_1 = __importDefault(require("../helper/modify-xml-helper"));
|
|
10
|
+
const modify_text_helper_1 = __importDefault(require("../helper/modify-text-helper"));
|
|
11
|
+
const modify_color_helper_1 = __importDefault(require("../helper/modify-color-helper"));
|
|
12
|
+
const index_1 = require("../index");
|
|
13
|
+
const modify_chart_helper_1 = __importDefault(require("../helper/modify-chart-helper"));
|
|
14
|
+
class ModifyChart {
|
|
15
|
+
constructor(chart, workbook, data, slot) {
|
|
16
|
+
this.sharedStringCache = {};
|
|
17
|
+
this.setSeriesDataLabels = () => {
|
|
18
|
+
this.data.series.forEach((series, s) => {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
if ((_a = series.style) === null || _a === void 0 ? void 0 : _a.label) {
|
|
21
|
+
this.chart.modify(this.series(s, this.seriesDataLabel(s, (_b = series.style) === null || _b === void 0 ? void 0 : _b.label)));
|
|
22
|
+
// Apply style for all label props helper if required
|
|
23
|
+
index_1.modify.setDataLabelAttributes(Object.assign({ applyToSeries: s }, (_c = series.style) === null || _c === void 0 ? void 0 : _c.label))(null, this.chart.root);
|
|
24
|
+
}
|
|
25
|
+
this.data.categories.forEach((category, c) => {
|
|
26
|
+
this.chart.modify(this.series(s, this.seriesDataLabelsRange(c, category.label)));
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
this.series = (index, children) => {
|
|
31
|
+
return {
|
|
32
|
+
'c:ser': {
|
|
33
|
+
index: index,
|
|
34
|
+
children: children,
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
this.chartPoint = (idx, style) => {
|
|
39
|
+
// Build the child tags first: only a style that yields at least one
|
|
40
|
+
// applicable modification may create a c:dPt. A pseudo-style (truthy keys
|
|
41
|
+
// without applicable content, e.g. a color without `type`) must not reach
|
|
42
|
+
// the XML layer — a point without explicit style inherits the series
|
|
43
|
+
// formatting, and fabricating one used to erase line charts.
|
|
44
|
+
const children = Object.assign(Object.assign({}, this.chartPointSpPr(style)), this.chartPointMarker(style === null || style === void 0 ? void 0 : style.marker));
|
|
45
|
+
if (!Object.keys(children).length)
|
|
46
|
+
return;
|
|
47
|
+
return {
|
|
48
|
+
'c:dPt': {
|
|
49
|
+
// c:dPt is sparse: one element per explicitly styled point, addressed
|
|
50
|
+
// by its <c:idx> payload — never by sibling position.
|
|
51
|
+
matchIdx: idx,
|
|
52
|
+
children,
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Fill and border share the point's single <c:spPr>; the border's <a:ln>
|
|
58
|
+
* is nested so that its creation lands inside the spPr, not on the c:dPt.
|
|
59
|
+
*/
|
|
60
|
+
this.chartPointSpPr = (style) => {
|
|
61
|
+
var _a;
|
|
62
|
+
const modify = [];
|
|
63
|
+
if ((_a = style === null || style === void 0 ? void 0 : style.color) === null || _a === void 0 ? void 0 : _a.type) {
|
|
64
|
+
modify.push(modify_color_helper_1.default.solidFill(style.color));
|
|
65
|
+
}
|
|
66
|
+
const border = this.chartPointBorder(style === null || style === void 0 ? void 0 : style.border);
|
|
67
|
+
if (!modify.length && !border)
|
|
68
|
+
return;
|
|
69
|
+
return {
|
|
70
|
+
'c:spPr': {
|
|
71
|
+
modify,
|
|
72
|
+
children: border,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
this.chartPointMarker = (markerStyle) => {
|
|
77
|
+
var _a;
|
|
78
|
+
// solidFill is a no-op without a typed color, so a marker style carrying
|
|
79
|
+
// none has nothing to modify. Per-point marker *creation* is unsupported:
|
|
80
|
+
// isRequired:false styles a c:marker where the template has one.
|
|
81
|
+
if (!((_a = markerStyle === null || markerStyle === void 0 ? void 0 : markerStyle.color) === null || _a === void 0 ? void 0 : _a.type))
|
|
82
|
+
return;
|
|
83
|
+
return {
|
|
84
|
+
'c:marker': {
|
|
85
|
+
isRequired: false,
|
|
86
|
+
children: {
|
|
87
|
+
'c:spPr': {
|
|
88
|
+
modify: modify_color_helper_1.default.solidFill(markerStyle.color),
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
this.chartPointBorder = (style) => {
|
|
95
|
+
var _a;
|
|
96
|
+
if (!style)
|
|
97
|
+
return;
|
|
98
|
+
const modify = [];
|
|
99
|
+
if ((_a = style.color) === null || _a === void 0 ? void 0 : _a.type) {
|
|
100
|
+
modify.push(modify_color_helper_1.default.solidFill(style.color));
|
|
101
|
+
modify.push(modify_color_helper_1.default.removeNoFill());
|
|
102
|
+
}
|
|
103
|
+
if (style.weight) {
|
|
104
|
+
modify.push(modify_xml_helper_1.default.attribute('w', style.weight));
|
|
105
|
+
}
|
|
106
|
+
if (!modify.length)
|
|
107
|
+
return;
|
|
108
|
+
return {
|
|
109
|
+
'a:ln': {
|
|
110
|
+
modify: modify,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
this.chartPointLabel = (idx, labelStyle) => {
|
|
115
|
+
if (!labelStyle)
|
|
116
|
+
return;
|
|
117
|
+
const suffixModify = labelStyle.suffix
|
|
118
|
+
? [
|
|
119
|
+
(element) => {
|
|
120
|
+
modify_chart_helper_1.default.setPointLabelSuffix(element, idx, labelStyle);
|
|
121
|
+
},
|
|
122
|
+
]
|
|
123
|
+
: [];
|
|
124
|
+
return {
|
|
125
|
+
'c:dLbls': {
|
|
126
|
+
children: {
|
|
127
|
+
'c:dLbl': {
|
|
128
|
+
// Like c:dPt, c:dLbl is a sparse per-point override addressed by
|
|
129
|
+
// its <c:idx> payload. A missing label is cloned from the clean
|
|
130
|
+
// state of the first existing one.
|
|
131
|
+
matchIdx: idx,
|
|
132
|
+
fromIndex: 0,
|
|
133
|
+
modify: suffixModify,
|
|
134
|
+
children: {
|
|
135
|
+
// Template content is styled where present, never fabricated.
|
|
136
|
+
'a:pPr': {
|
|
137
|
+
isRequired: false,
|
|
138
|
+
children: {
|
|
139
|
+
'a:defRPr': {
|
|
140
|
+
isRequired: false,
|
|
141
|
+
modify: [
|
|
142
|
+
modify_color_helper_1.default.solidFill(labelStyle === null || labelStyle === void 0 ? void 0 : labelStyle.color),
|
|
143
|
+
modify_text_helper_1.default.style(labelStyle),
|
|
144
|
+
],
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
'a:fld': {
|
|
149
|
+
isRequired: false,
|
|
150
|
+
children: {
|
|
151
|
+
'a:rPr': {
|
|
152
|
+
isRequired: false,
|
|
153
|
+
modify: [
|
|
154
|
+
modify_color_helper_1.default.solidFill(labelStyle === null || labelStyle === void 0 ? void 0 : labelStyle.color),
|
|
155
|
+
modify_text_helper_1.default.style(labelStyle),
|
|
156
|
+
],
|
|
157
|
+
},
|
|
158
|
+
'a:defRPr': {
|
|
159
|
+
isRequired: false,
|
|
160
|
+
modify: [
|
|
161
|
+
modify_color_helper_1.default.solidFill(labelStyle === null || labelStyle === void 0 ? void 0 : labelStyle.color),
|
|
162
|
+
modify_text_helper_1.default.style(labelStyle),
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
this.seriesId = (series) => {
|
|
174
|
+
return {
|
|
175
|
+
'c:idx': {
|
|
176
|
+
modify: modify_xml_helper_1.default.attribute('val', series),
|
|
177
|
+
},
|
|
178
|
+
'c:order': {
|
|
179
|
+
modify: modify_xml_helper_1.default.attribute('val', series + 1),
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
this.seriesLabel = (label, series) => {
|
|
184
|
+
return {
|
|
185
|
+
'c:f': {
|
|
186
|
+
modify: modify_xml_helper_1.default.range(series + 1),
|
|
187
|
+
},
|
|
188
|
+
'c:v': {
|
|
189
|
+
modify: modify_text_helper_1.default.content(label),
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
this.extSeriesLabel = (label, series) => {
|
|
194
|
+
return {
|
|
195
|
+
'cx:f': {
|
|
196
|
+
modify: modify_xml_helper_1.default.range(series + 1),
|
|
197
|
+
},
|
|
198
|
+
'cx:v': {
|
|
199
|
+
modify: modify_text_helper_1.default.content(label),
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
this.seriesStyle = (series) => {
|
|
204
|
+
var _a;
|
|
205
|
+
if (!(series === null || series === void 0 ? void 0 : series.style))
|
|
206
|
+
return;
|
|
207
|
+
return {
|
|
208
|
+
'c:spPr': {
|
|
209
|
+
modify: modify_color_helper_1.default.solidFill(series.style.color),
|
|
210
|
+
},
|
|
211
|
+
'c:marker': {
|
|
212
|
+
isRequired: false,
|
|
213
|
+
children: {
|
|
214
|
+
'c:spPr': {
|
|
215
|
+
isRequired: false,
|
|
216
|
+
modify: modify_color_helper_1.default.solidFill((_a = series.style.marker) === null || _a === void 0 ? void 0 : _a.color),
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
this.seriesDataLabelsRange = (r, value) => {
|
|
223
|
+
return {
|
|
224
|
+
'c15:datalabelsRange': {
|
|
225
|
+
isRequired: false,
|
|
226
|
+
children: {
|
|
227
|
+
'c:pt': {
|
|
228
|
+
index: r,
|
|
229
|
+
modify: modify_xml_helper_1.default.value(value, r),
|
|
230
|
+
},
|
|
231
|
+
'c15:f': {
|
|
232
|
+
modify: modify_xml_helper_1.default.range(0, this.height),
|
|
233
|
+
},
|
|
234
|
+
'c:ptCount': {
|
|
235
|
+
modify: modify_xml_helper_1.default.attribute('val', this.height),
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
this.seriesDataLabel = (s, style) => {
|
|
242
|
+
return {
|
|
243
|
+
'c:dLbls': {
|
|
244
|
+
isRequired: false,
|
|
245
|
+
children: {
|
|
246
|
+
'a:pPr': {
|
|
247
|
+
modify: modify_color_helper_1.default.solidFill(style === null || style === void 0 ? void 0 : style.color),
|
|
248
|
+
children: {
|
|
249
|
+
'a:defRPr': {
|
|
250
|
+
modify: modify_text_helper_1.default.style(style),
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
this.extPoint = (r, c, value) => {
|
|
259
|
+
return {
|
|
260
|
+
children: {
|
|
261
|
+
'cx:pt': {
|
|
262
|
+
index: r,
|
|
263
|
+
modify: [
|
|
264
|
+
modify_xml_helper_1.default.attribute('idx', r),
|
|
265
|
+
modify_xml_helper_1.default.textContent(value),
|
|
266
|
+
],
|
|
267
|
+
},
|
|
268
|
+
'cx:f': {
|
|
269
|
+
modify: modify_xml_helper_1.default.range(c, this.height),
|
|
270
|
+
},
|
|
271
|
+
'cx:lvl': {
|
|
272
|
+
modify: modify_xml_helper_1.default.attribute('ptCount', this.height),
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
};
|
|
276
|
+
};
|
|
277
|
+
this.extSeries = (index, children) => {
|
|
278
|
+
return {
|
|
279
|
+
'cx:series': {
|
|
280
|
+
index: index,
|
|
281
|
+
children: children,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
this.point = (r, c, value) => {
|
|
286
|
+
return {
|
|
287
|
+
children: {
|
|
288
|
+
'c:pt': {
|
|
289
|
+
index: r,
|
|
290
|
+
modify: modify_xml_helper_1.default.value(modify_chart_helper_1.default.parseCellValue(value), r),
|
|
291
|
+
},
|
|
292
|
+
'c:f': {
|
|
293
|
+
modify: modify_xml_helper_1.default.range(c, this.height),
|
|
294
|
+
},
|
|
295
|
+
'c:ptCount': {
|
|
296
|
+
modify: modify_xml_helper_1.default.attribute('val', this.height),
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
this.data = data;
|
|
302
|
+
// XmlHelper.dump(chart)
|
|
303
|
+
this.chart = new modify_xml_helper_1.default(chart);
|
|
304
|
+
this.workbook = new modify_xml_helper_1.default(workbook.sheet);
|
|
305
|
+
this.workbookTable = workbook.table
|
|
306
|
+
? new modify_xml_helper_1.default(workbook.table)
|
|
307
|
+
: null;
|
|
308
|
+
this.sharedStrings = workbook.sharedStrings;
|
|
309
|
+
this.columns = this.setColumns(slot);
|
|
310
|
+
this.height = this.data.categories.length;
|
|
311
|
+
this.width = this.columns.length;
|
|
312
|
+
}
|
|
313
|
+
modify() {
|
|
314
|
+
this.setValues();
|
|
315
|
+
this.setSeries();
|
|
316
|
+
this.setSeriesDataLabels();
|
|
317
|
+
this.setPointStyles();
|
|
318
|
+
this.sliceChartSpace();
|
|
319
|
+
this.modifyWorkbook();
|
|
320
|
+
// XmlHelper.dump(this.chart.root as XmlDocument)
|
|
321
|
+
}
|
|
322
|
+
modifyExtended() {
|
|
323
|
+
this.setExtData();
|
|
324
|
+
this.setExtSeries();
|
|
325
|
+
this.sliceExtChartSpace();
|
|
326
|
+
this.modifyWorkbook();
|
|
327
|
+
}
|
|
328
|
+
modifyWorkbook() {
|
|
329
|
+
this.prepareWorkbook();
|
|
330
|
+
this.setWorkbook();
|
|
331
|
+
this.sliceWorkbook();
|
|
332
|
+
if (this.workbookTable) {
|
|
333
|
+
this.setWorkbookTable();
|
|
334
|
+
this.sliceWorkbookTable();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
setColumns(slots) {
|
|
338
|
+
const columns = [];
|
|
339
|
+
slots.forEach((slot) => {
|
|
340
|
+
const series = slot.series;
|
|
341
|
+
const index = slot.index;
|
|
342
|
+
const targetCol = slot.targetCol;
|
|
343
|
+
const targetYCol = slot.targetYCol || 1;
|
|
344
|
+
const label = slot.label ? slot.label : series.label;
|
|
345
|
+
const mapData = slot.mapData !== undefined ? slot.mapData : (point) => point;
|
|
346
|
+
const isStrRef = slot.isStrRef !== undefined ? slot.isStrRef : true;
|
|
347
|
+
const worksheetCb = (point, r, category) => {
|
|
348
|
+
return this.workbook.modify(this.rowValues(r, targetCol, mapData(point, category)));
|
|
349
|
+
};
|
|
350
|
+
const slotHandler = slot.type !== undefined
|
|
351
|
+
? this[slot.type]
|
|
352
|
+
: undefined;
|
|
353
|
+
const chartCb = typeof slotHandler === 'function'
|
|
354
|
+
? (point, r, category) => {
|
|
355
|
+
return slotHandler.call(this, r, targetCol, point, category, slot.tag, mapData, targetYCol);
|
|
356
|
+
}
|
|
357
|
+
: null;
|
|
358
|
+
const column = {
|
|
359
|
+
series: index,
|
|
360
|
+
label: label,
|
|
361
|
+
worksheet: worksheetCb,
|
|
362
|
+
chart: chartCb,
|
|
363
|
+
isStrRef: isStrRef,
|
|
364
|
+
};
|
|
365
|
+
columns.push(column);
|
|
366
|
+
});
|
|
367
|
+
return columns;
|
|
368
|
+
}
|
|
369
|
+
setValues() {
|
|
370
|
+
this.setValuesByCategory((col) => {
|
|
371
|
+
return this.series(col.series, col.modTags);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
setExtData() {
|
|
375
|
+
this.setValuesByCategory((col) => {
|
|
376
|
+
return {
|
|
377
|
+
'cx:data': {
|
|
378
|
+
children: col.modTags,
|
|
379
|
+
},
|
|
380
|
+
};
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
setValuesByCategory(cb) {
|
|
384
|
+
this.data.categories.forEach((category, c) => {
|
|
385
|
+
this.columns
|
|
386
|
+
.filter((col) => col.chart)
|
|
387
|
+
.forEach((col) => {
|
|
388
|
+
if (category.values[col.series] === undefined) {
|
|
389
|
+
throw new Error(`No value for category "${category.label}" at series "${col.label}".`);
|
|
390
|
+
}
|
|
391
|
+
col.modTags = col.chart(category.values[col.series], c, category);
|
|
392
|
+
this.chart.modify(cb(col));
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
}
|
|
396
|
+
setPointStyles() {
|
|
397
|
+
this.data.categories.forEach((category, c) => {
|
|
398
|
+
if (category.styles) {
|
|
399
|
+
category.styles.forEach((style, s) => {
|
|
400
|
+
if (style === null || !Object.values(style).length)
|
|
401
|
+
return;
|
|
402
|
+
const pointTags = this.chartPoint(c, style);
|
|
403
|
+
if (pointTags) {
|
|
404
|
+
this.chart.modify(this.series(s, pointTags));
|
|
405
|
+
}
|
|
406
|
+
if (style.label) {
|
|
407
|
+
this.chart.modify(this.series(s, this.chartPointLabel(c, style.label)));
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
setSeries() {
|
|
414
|
+
this.columns.forEach((column, colId) => {
|
|
415
|
+
if (column.isStrRef === true) {
|
|
416
|
+
this.chart.modify(this.series(column.series, Object.assign(Object.assign(Object.assign({}, this.seriesId(column.series)), this.seriesLabel(column.label, colId)), this.seriesStyle(this.data.series[column.series]))));
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
setExtSeries() {
|
|
421
|
+
this.columns.forEach((column, colId) => {
|
|
422
|
+
if (column.isStrRef === true) {
|
|
423
|
+
this.chart.modify(this.extSeries(column.series, Object.assign({}, this.extSeriesLabel(column.label, colId))));
|
|
424
|
+
}
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
sliceChartSpace() {
|
|
428
|
+
this.chart.modify({
|
|
429
|
+
'c:plotArea': this.slice('c:ser', this.data.series.length),
|
|
430
|
+
});
|
|
431
|
+
this.columns
|
|
432
|
+
.filter((column) => column.modTags)
|
|
433
|
+
.forEach((column) => {
|
|
434
|
+
const sliceMod = {};
|
|
435
|
+
Object.keys(column.modTags).forEach((tag) => {
|
|
436
|
+
sliceMod[tag] = this.slice('c:pt', this.height);
|
|
437
|
+
});
|
|
438
|
+
this.chart.modify(this.series(column.series, sliceMod));
|
|
439
|
+
});
|
|
440
|
+
}
|
|
441
|
+
sliceExtChartSpace() {
|
|
442
|
+
this.chart.modify({
|
|
443
|
+
'cx:plotArea': this.slice('cx:series', this.data.series.length),
|
|
444
|
+
});
|
|
445
|
+
this.columns
|
|
446
|
+
.filter((column) => column.modTags)
|
|
447
|
+
.forEach((column) => {
|
|
448
|
+
const sliceMod = {};
|
|
449
|
+
Object.keys(column.modTags).forEach((tag) => {
|
|
450
|
+
sliceMod[tag] = this.slice('cx:pt', this.height);
|
|
451
|
+
});
|
|
452
|
+
this.chart.modify({
|
|
453
|
+
'cx:data': { index: column.series, children: sliceMod },
|
|
454
|
+
});
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
/*
|
|
458
|
+
There might be rows in an excel workbook that appear to be empty, but
|
|
459
|
+
contain either no cells or none with a "v"-tag. These rows are removed
|
|
460
|
+
by prepareWorkbook(). See https://github.com/singerla/pptx-automizer/issues/11
|
|
461
|
+
*/
|
|
462
|
+
prepareWorkbook() {
|
|
463
|
+
const rows = this.workbook.root.getElementsByTagName('row');
|
|
464
|
+
for (const r in rows) {
|
|
465
|
+
if (!rows[r].getElementsByTagName)
|
|
466
|
+
continue;
|
|
467
|
+
const values = rows[r].getElementsByTagName('v');
|
|
468
|
+
if (values.length === 0) {
|
|
469
|
+
const toRemove = rows[r];
|
|
470
|
+
toRemove.parentNode.removeChild(toRemove);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
this.normalizeCellPositions();
|
|
474
|
+
}
|
|
475
|
+
/*
|
|
476
|
+
Excel skips the <c>-tag of an empty cell, e.g. a chart worksheet with an
|
|
477
|
+
empty top left cell has no <c r="A1"/> at all. All worksheet modifications
|
|
478
|
+
address a cell by its position inside a <row>, so any gap would shift all
|
|
479
|
+
following cells and finally create duplicate cell addresses.
|
|
480
|
+
Inserting a blank cell for each gap restores "nth cell equals nth column".
|
|
481
|
+
See https://github.com/singerla/pptx-automizer/issues/39
|
|
482
|
+
*/
|
|
483
|
+
normalizeCellPositions() {
|
|
484
|
+
const rows = this.workbook.root.getElementsByTagName('row');
|
|
485
|
+
for (let r = 0; r < rows.length; r++) {
|
|
486
|
+
this.insertMissingCells(rows[r]);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
insertMissingCells(row) {
|
|
490
|
+
const cells = Array.from(row.getElementsByTagName('c'));
|
|
491
|
+
const rowNumber = this.getRowNumber(row, cells);
|
|
492
|
+
if (rowNumber === null) {
|
|
493
|
+
return;
|
|
494
|
+
}
|
|
495
|
+
let expectedColumn = 0;
|
|
496
|
+
cells.forEach((cell) => {
|
|
497
|
+
const column = cell_id_helper_1.default.getColumnIndex(cell.getAttribute('r'));
|
|
498
|
+
if (column === null || column < expectedColumn) {
|
|
499
|
+
// A cell without a parsable address is assumed to be in place.
|
|
500
|
+
expectedColumn++;
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
while (expectedColumn < column) {
|
|
504
|
+
row.insertBefore(this.blankCell(expectedColumn, rowNumber), cell);
|
|
505
|
+
expectedColumn++;
|
|
506
|
+
}
|
|
507
|
+
expectedColumn = column + 1;
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
getRowNumber(row, cells) {
|
|
511
|
+
const rowNumber = Number(row.getAttribute('r'));
|
|
512
|
+
if (rowNumber) {
|
|
513
|
+
return rowNumber;
|
|
514
|
+
}
|
|
515
|
+
// A <row> without "r"-attribute can still be identified by its cells.
|
|
516
|
+
for (const cell of cells) {
|
|
517
|
+
const cellRow = cell_id_helper_1.default.getRowNumber(cell.getAttribute('r'));
|
|
518
|
+
if (cellRow) {
|
|
519
|
+
return cellRow;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
return null;
|
|
523
|
+
}
|
|
524
|
+
blankCell(c, rowNumber) {
|
|
525
|
+
const doc = this.workbook.root.ownerDocument || this.workbook.root;
|
|
526
|
+
const label = this.blankCellLabel(c, rowNumber);
|
|
527
|
+
const value = doc.createElement('v');
|
|
528
|
+
value.appendChild(doc.createTextNode(String(this.getSharedString(label))));
|
|
529
|
+
const cell = doc.createElement('c');
|
|
530
|
+
cell.setAttribute('r', cell_id_helper_1.default.getCellAddressString(c, rowNumber - 1));
|
|
531
|
+
cell.setAttribute('t', 's');
|
|
532
|
+
cell.appendChild(value);
|
|
533
|
+
return cell;
|
|
534
|
+
}
|
|
535
|
+
/*
|
|
536
|
+
A blank cell holds a single space, just like PowerPoint does for the empty
|
|
537
|
+
top left cell of a default chart worksheet. If the worksheet contains a
|
|
538
|
+
table, a header cell needs to match the name of its tableColumn, otherwise
|
|
539
|
+
Excel is going to repair the workbook.
|
|
540
|
+
*/
|
|
541
|
+
blankCellLabel(c, rowNumber) {
|
|
542
|
+
if (rowNumber !== 1 || !this.workbookTable) {
|
|
543
|
+
return ' ';
|
|
544
|
+
}
|
|
545
|
+
const column = this.workbookTable.root.getElementsByTagName('tableColumn')[c];
|
|
546
|
+
return column ? column.getAttribute('name') : ' ';
|
|
547
|
+
}
|
|
548
|
+
/*
|
|
549
|
+
Re-uses an existing shared string to not grow the worksheet on each
|
|
550
|
+
inserted cell.
|
|
551
|
+
*/
|
|
552
|
+
getSharedString(label) {
|
|
553
|
+
if (this.sharedStringCache[label] === undefined) {
|
|
554
|
+
const strings = this.sharedStrings.getElementsByTagName('si');
|
|
555
|
+
for (let i = 0; i < strings.length; i++) {
|
|
556
|
+
if (strings[i].textContent === label) {
|
|
557
|
+
this.sharedStringCache[label] = i;
|
|
558
|
+
return i;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
this.sharedStringCache[label] = xml_helper_1.XmlHelper.appendSharedString(this.sharedStrings, label);
|
|
562
|
+
}
|
|
563
|
+
return this.sharedStringCache[label];
|
|
564
|
+
}
|
|
565
|
+
setWorkbook() {
|
|
566
|
+
this.workbook.modify(this.spanString());
|
|
567
|
+
this.workbook.modify(this.rowAttributes(0, 1));
|
|
568
|
+
this.data.categories.forEach((category, c) => {
|
|
569
|
+
const r = c + 1;
|
|
570
|
+
this.workbook.modify(this.rowLabels(r, category.label));
|
|
571
|
+
this.workbook.modify(this.rowAttributes(r, r + 1));
|
|
572
|
+
this.columns.forEach((addCol) => addCol.worksheet(category.values[addCol.series], r, category));
|
|
573
|
+
});
|
|
574
|
+
this.columns.forEach((addCol, s) => {
|
|
575
|
+
this.workbook.modify(this.colLabel(s + 1, addCol.label));
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
sliceWorkbook() {
|
|
579
|
+
this.data.categories.forEach((category, c) => {
|
|
580
|
+
const r = c + 1;
|
|
581
|
+
this.workbook.modify({
|
|
582
|
+
row: Object.assign({ index: r }, this.slice('c', this.width + 1)),
|
|
583
|
+
});
|
|
584
|
+
});
|
|
585
|
+
this.workbook.modify({
|
|
586
|
+
row: Object.assign({}, this.slice('c', this.width + 1)),
|
|
587
|
+
});
|
|
588
|
+
this.workbook.modify({
|
|
589
|
+
sheetData: this.slice('row', this.height + 1),
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
defaultSeries(r, targetCol, point, category) {
|
|
593
|
+
return {
|
|
594
|
+
'c:val': this.point(r, targetCol, point),
|
|
595
|
+
'c:cat': this.point(r, 0, category.label),
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
xySeries(r, targetCol, point, category, tag, mapData, targetYCol) {
|
|
599
|
+
return {
|
|
600
|
+
'c:xVal': this.point(r, targetCol, point),
|
|
601
|
+
'c:yVal': this.point(r, targetYCol, category.y),
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
customSeries(r, targetCol, point, category, tag, mapData) {
|
|
605
|
+
return {
|
|
606
|
+
[tag]: this.point(r, targetCol, mapData(point, category)),
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
extendedSeries(r, targetCol, point, category) {
|
|
610
|
+
return {
|
|
611
|
+
'cx:strDim': this.extPoint(r, 0, category.label),
|
|
612
|
+
'cx:numDim': this.extPoint(r, targetCol, point),
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
colLabel(c, label) {
|
|
616
|
+
return {
|
|
617
|
+
row: {
|
|
618
|
+
modify: modify_xml_helper_1.default.attribute('spans', `1:${this.width}`),
|
|
619
|
+
children: {
|
|
620
|
+
c: {
|
|
621
|
+
index: c,
|
|
622
|
+
modify: [
|
|
623
|
+
modify_xml_helper_1.default.attribute('r', cell_id_helper_1.default.getCellAddressString(c, 0)),
|
|
624
|
+
// A label always refers to a shared string.
|
|
625
|
+
modify_xml_helper_1.default.attribute('t', 's'),
|
|
626
|
+
],
|
|
627
|
+
children: this.sharedString(label),
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
},
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
rowAttributes(r, rowId) {
|
|
634
|
+
return {
|
|
635
|
+
row: {
|
|
636
|
+
index: r,
|
|
637
|
+
fromPrevious: true,
|
|
638
|
+
modify: [
|
|
639
|
+
modify_xml_helper_1.default.attribute('spans', `1:${this.width}`),
|
|
640
|
+
modify_xml_helper_1.default.attribute('r', String(rowId)),
|
|
641
|
+
],
|
|
642
|
+
},
|
|
643
|
+
};
|
|
644
|
+
}
|
|
645
|
+
rowLabels(r, label) {
|
|
646
|
+
return {
|
|
647
|
+
row: {
|
|
648
|
+
index: r,
|
|
649
|
+
fromPrevious: true,
|
|
650
|
+
children: {
|
|
651
|
+
c: {
|
|
652
|
+
modify: [
|
|
653
|
+
modify_xml_helper_1.default.attribute('r', cell_id_helper_1.default.getCellAddressString(0, r)),
|
|
654
|
+
// A label always refers to a shared string.
|
|
655
|
+
modify_xml_helper_1.default.attribute('t', 's'),
|
|
656
|
+
],
|
|
657
|
+
children: this.sharedString(label),
|
|
658
|
+
},
|
|
659
|
+
},
|
|
660
|
+
},
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
rowValues(r, c, value) {
|
|
664
|
+
return {
|
|
665
|
+
row: {
|
|
666
|
+
index: r,
|
|
667
|
+
fromPrevious: true,
|
|
668
|
+
children: {
|
|
669
|
+
c: {
|
|
670
|
+
index: c,
|
|
671
|
+
fromPrevious: true,
|
|
672
|
+
modify: [
|
|
673
|
+
modify_xml_helper_1.default.attribute('r', cell_id_helper_1.default.getCellAddressString(c, r)),
|
|
674
|
+
// A chart value is numeric, it must not point to a shared string,
|
|
675
|
+
// e.g. if the cell was blank in the source worksheet.
|
|
676
|
+
modify_xml_helper_1.default.removeAttribute('t'),
|
|
677
|
+
],
|
|
678
|
+
children: this.cellValue(modify_chart_helper_1.default.parseCellValue(value)),
|
|
679
|
+
},
|
|
680
|
+
},
|
|
681
|
+
},
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
slice(tag, length) {
|
|
685
|
+
return {
|
|
686
|
+
children: {
|
|
687
|
+
[tag]: {
|
|
688
|
+
collection: (collection) => {
|
|
689
|
+
xml_helper_1.XmlHelper.sliceCollection(collection, length);
|
|
690
|
+
},
|
|
691
|
+
},
|
|
692
|
+
},
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
spanString() {
|
|
696
|
+
return {
|
|
697
|
+
dimension: {
|
|
698
|
+
modify: modify_xml_helper_1.default.attribute('ref', cell_id_helper_1.default.getSpanString(0, 1, this.width, this.height)),
|
|
699
|
+
},
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
cellValue(value) {
|
|
703
|
+
return {
|
|
704
|
+
v: {
|
|
705
|
+
modify: modify_text_helper_1.default.content(value),
|
|
706
|
+
},
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
sharedString(label) {
|
|
710
|
+
return this.cellValue(xml_helper_1.XmlHelper.appendSharedString(this.sharedStrings, label));
|
|
711
|
+
}
|
|
712
|
+
setWorkbookTable() {
|
|
713
|
+
this.workbookTable.modify({
|
|
714
|
+
table: {
|
|
715
|
+
modify: modify_xml_helper_1.default.attribute('ref', cell_id_helper_1.default.getSpanString(0, 1, this.width, this.height)),
|
|
716
|
+
},
|
|
717
|
+
tableColumns: {
|
|
718
|
+
modify: modify_xml_helper_1.default.attribute('count', this.width + 1),
|
|
719
|
+
},
|
|
720
|
+
});
|
|
721
|
+
this.setWorkbookTableFirstColumn();
|
|
722
|
+
this.columns.forEach((addCol, s) => {
|
|
723
|
+
this.setWorkbookTableColumn(s + 1, addCol.label);
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
setWorkbookTableFirstColumn() {
|
|
727
|
+
this.workbookTable.modify({
|
|
728
|
+
tableColumn: {
|
|
729
|
+
index: 0,
|
|
730
|
+
modify: modify_xml_helper_1.default.attribute('id', 1),
|
|
731
|
+
},
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
setWorkbookTableColumn(c, label) {
|
|
735
|
+
this.workbookTable.modify({
|
|
736
|
+
tableColumn: {
|
|
737
|
+
index: c,
|
|
738
|
+
fromPrevious: true,
|
|
739
|
+
modify: [
|
|
740
|
+
modify_xml_helper_1.default.attribute('id', c + 1),
|
|
741
|
+
modify_xml_helper_1.default.attribute('name', label),
|
|
742
|
+
],
|
|
743
|
+
},
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
sliceWorkbookTable() {
|
|
747
|
+
this.workbookTable.modify({
|
|
748
|
+
table: this.slice('tableColumn', this.width + 1),
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
exports.ModifyChart = ModifyChart;
|
|
753
|
+
//# sourceMappingURL=modify-chart.js.map
|