@devmm/puredocs-excel-charts 1.1.2 → 1.1.4
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/dist/index.cjs +144 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +144 -168
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var puredocsExcel = require('@devmm/puredocs-excel');
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
throw TypeError(msg);
|
|
7
|
-
};
|
|
8
|
-
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
9
|
-
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
10
|
-
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
11
|
-
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
12
|
-
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
5
|
+
// src/excel-chart.ts
|
|
13
6
|
|
|
14
7
|
// src/chart-enums.ts
|
|
15
8
|
var ExcelChartType = /* @__PURE__ */ ((ExcelChartType2) => {
|
|
@@ -114,26 +107,24 @@ function numRef(ref) {
|
|
|
114
107
|
function strRef(ref) {
|
|
115
108
|
return `<c:strRef><c:f>${puredocsExcel.escapeXml(ref)}</c:f></c:strRef>`;
|
|
116
109
|
}
|
|
117
|
-
var
|
|
118
|
-
|
|
110
|
+
var ExcelChart = class _ExcelChart {
|
|
111
|
+
#type;
|
|
112
|
+
#family;
|
|
113
|
+
#secondaryType = "line" /* Line */;
|
|
114
|
+
#anchor = { fromCol: 0, fromRow: 0, toCol: 8, toRow: 15 };
|
|
115
|
+
#title;
|
|
116
|
+
#series = [];
|
|
117
|
+
#legend = { position: "r" /* Right */ };
|
|
118
|
+
#categoryAxis = {};
|
|
119
|
+
#valueAxis = { majorGridlines: true };
|
|
120
|
+
#secondaryValueAxis = {};
|
|
121
|
+
#dataLabels;
|
|
122
|
+
#gapWidth = 150;
|
|
123
|
+
#holeSize;
|
|
119
124
|
constructor(type) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
__privateAdd(this, _secondaryType, "line" /* Line */);
|
|
124
|
-
__privateAdd(this, _anchor, { fromCol: 0, fromRow: 0, toCol: 8, toRow: 15 });
|
|
125
|
-
__privateAdd(this, _title);
|
|
126
|
-
__privateAdd(this, _series, []);
|
|
127
|
-
__privateAdd(this, _legend, { position: "r" /* Right */ });
|
|
128
|
-
__privateAdd(this, _categoryAxis, {});
|
|
129
|
-
__privateAdd(this, _valueAxis, { majorGridlines: true });
|
|
130
|
-
__privateAdd(this, _secondaryValueAxis, {});
|
|
131
|
-
__privateAdd(this, _dataLabels);
|
|
132
|
-
__privateAdd(this, _gapWidth, 150);
|
|
133
|
-
__privateAdd(this, _holeSize);
|
|
134
|
-
__privateSet(this, _type, type);
|
|
135
|
-
__privateSet(this, _family, resolveFamily(type));
|
|
136
|
-
__privateSet(this, _holeSize, __privateGet(this, _family).holeSize);
|
|
125
|
+
this.#type = type;
|
|
126
|
+
this.#family = resolveFamily(type);
|
|
127
|
+
this.#holeSize = this.#family.holeSize;
|
|
137
128
|
}
|
|
138
129
|
/** Creates a chart of the given type. */
|
|
139
130
|
static create(type) {
|
|
@@ -141,59 +132,59 @@ var _ExcelChart = class _ExcelChart {
|
|
|
141
132
|
}
|
|
142
133
|
/** The chart type. */
|
|
143
134
|
get type() {
|
|
144
|
-
return
|
|
135
|
+
return this.#type;
|
|
145
136
|
}
|
|
146
137
|
// ── Fluent configuration ──────────────────────────────────────────────────
|
|
147
138
|
setAnchor(anchor) {
|
|
148
139
|
if ("from" in anchor) {
|
|
149
140
|
const f = puredocsExcel.parseCellRef(anchor.from);
|
|
150
141
|
const t = puredocsExcel.parseCellRef(anchor.to);
|
|
151
|
-
|
|
142
|
+
this.#anchor = { fromCol: f.column - 1, fromRow: f.row - 1, toCol: t.column - 1, toRow: t.row - 1 };
|
|
152
143
|
} else {
|
|
153
|
-
|
|
144
|
+
this.#anchor = { fromCol: anchor.fromCol, fromRow: anchor.fromRow, toCol: anchor.toCol, toRow: anchor.toRow };
|
|
154
145
|
}
|
|
155
146
|
return this;
|
|
156
147
|
}
|
|
157
148
|
setTitle(title) {
|
|
158
|
-
|
|
149
|
+
this.#title = title;
|
|
159
150
|
return this;
|
|
160
151
|
}
|
|
161
152
|
addSeries(series) {
|
|
162
|
-
|
|
153
|
+
this.#series.push(series);
|
|
163
154
|
return this;
|
|
164
155
|
}
|
|
165
156
|
configureLegend(fn) {
|
|
166
|
-
fn(
|
|
157
|
+
fn(this.#legend);
|
|
167
158
|
return this;
|
|
168
159
|
}
|
|
169
160
|
configureCategoryAxis(fn) {
|
|
170
|
-
fn(
|
|
161
|
+
fn(this.#categoryAxis);
|
|
171
162
|
return this;
|
|
172
163
|
}
|
|
173
164
|
configureValueAxis(fn) {
|
|
174
|
-
fn(
|
|
165
|
+
fn(this.#valueAxis);
|
|
175
166
|
return this;
|
|
176
167
|
}
|
|
177
168
|
configureSecondaryValueAxis(fn) {
|
|
178
|
-
fn(
|
|
169
|
+
fn(this.#secondaryValueAxis);
|
|
179
170
|
return this;
|
|
180
171
|
}
|
|
181
172
|
/** Chart type used for series flagged `secondaryAxis` (default `Line`). */
|
|
182
173
|
setSecondaryType(type) {
|
|
183
|
-
|
|
174
|
+
this.#secondaryType = type;
|
|
184
175
|
return this;
|
|
185
176
|
}
|
|
186
177
|
showDataLabels(config = { value: true }) {
|
|
187
|
-
|
|
178
|
+
this.#dataLabels = config;
|
|
188
179
|
return this;
|
|
189
180
|
}
|
|
190
181
|
setGapWidth(gapWidth) {
|
|
191
|
-
|
|
182
|
+
this.#gapWidth = gapWidth;
|
|
192
183
|
return this;
|
|
193
184
|
}
|
|
194
185
|
/** Doughnut hole size as a percentage (10–90). Ignored by non-doughnut charts. */
|
|
195
186
|
setHoleSize(percent) {
|
|
196
|
-
|
|
187
|
+
this.#holeSize = percent;
|
|
197
188
|
return this;
|
|
198
189
|
}
|
|
199
190
|
/** Attaches this chart to a worksheet. */
|
|
@@ -203,7 +194,7 @@ var _ExcelChart = class _ExcelChart {
|
|
|
203
194
|
}
|
|
204
195
|
// ── DrawingProvider contract ──────────────────────────────────────────────
|
|
205
196
|
buildAnchorXml(relationshipId) {
|
|
206
|
-
const a =
|
|
197
|
+
const a = this.#anchor;
|
|
207
198
|
const frameId = parseInt(relationshipId.slice(3), 10) + 1;
|
|
208
199
|
return `<xdr:twoCellAnchor><xdr:from><xdr:col>${a.fromCol}</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>${a.fromRow}</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:from><xdr:to><xdr:col>${a.toCol}</xdr:col><xdr:colOff>0</xdr:colOff><xdr:row>${a.toRow}</xdr:row><xdr:rowOff>0</xdr:rowOff></xdr:to><xdr:graphicFrame macro=""><xdr:nvGraphicFramePr><xdr:cNvPr id="${frameId}" name="Chart ${frameId}"/><xdr:cNvGraphicFramePr/></xdr:nvGraphicFramePr><xdr:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/></xdr:xfrm><a:graphic><a:graphicData uri="${CHART_NS}"><c:chart xmlns:c="${CHART_NS}" xmlns:r="${puredocsExcel.NS.relationships}" r:id="${relationshipId}"/></a:graphicData></a:graphic></xdr:graphicFrame><xdr:clientData/></xdr:twoCellAnchor>`;
|
|
209
200
|
}
|
|
@@ -215,146 +206,131 @@ var _ExcelChart = class _ExcelChart {
|
|
|
215
206
|
relType: puredocsExcel.REL_TYPES.chart
|
|
216
207
|
};
|
|
217
208
|
}
|
|
209
|
+
// ── Chart XML ─────────────────────────────────────────────────────────────
|
|
210
|
+
/** True when a secondary-axis combo should be emitted. */
|
|
211
|
+
#hasSecondary() {
|
|
212
|
+
return CARTESIAN.has(this.#family.element) && this.#series.some((s) => s.secondaryAxis);
|
|
213
|
+
}
|
|
218
214
|
/** Builds the full `xl/charts/chartN.xml` content. */
|
|
219
215
|
toChartXml() {
|
|
220
|
-
const titleXml =
|
|
221
|
-
const plot =
|
|
222
|
-
const axes =
|
|
223
|
-
const legend =
|
|
216
|
+
const titleXml = this.#title ? `${this.#buildTitleXml(this.#title)}<c:autoTitleDeleted val="0"/>` : `<c:autoTitleDeleted val="1"/>`;
|
|
217
|
+
const plot = this.#buildPlotElement();
|
|
218
|
+
const axes = this.#family.hasAxes ? this.#buildAxesXml() : "";
|
|
219
|
+
const legend = this.#legend.position === "none" /* None */ ? "" : `<c:legend><c:legendPos val="${this.#legend.position}"/><c:overlay val="0"/></c:legend>`;
|
|
224
220
|
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?><c:chartSpace xmlns:c="${CHART_NS}" xmlns:a="${puredocsExcel.NS.drawingml}" xmlns:r="${puredocsExcel.NS.relationships}"><c:chart>` + titleXml + `<c:plotArea><c:layout/>` + plot + axes + `</c:plotArea>` + legend + `<c:plotVisOnly val="1"/><c:dispBlanksAs val="gap"/></c:chart></c:chartSpace>`;
|
|
225
221
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return
|
|
222
|
+
#buildPlotElement() {
|
|
223
|
+
const fam = this.#family;
|
|
224
|
+
const el = fam.element;
|
|
225
|
+
const indexed = this.#series.map((s, idx) => ({ s, idx }));
|
|
226
|
+
const dLbls = this.#buildDataLabelsXml();
|
|
227
|
+
if (el === "pieChart") {
|
|
228
|
+
return `<c:pieChart><c:varyColors val="1"/>${this.#seriesGroupXml(indexed, fam)}${dLbls}<c:firstSliceAng val="0"/></c:pieChart>`;
|
|
229
|
+
}
|
|
230
|
+
if (el === "doughnutChart") {
|
|
231
|
+
return `<c:doughnutChart><c:varyColors val="1"/>${this.#seriesGroupXml(indexed, fam)}${dLbls}<c:firstSliceAng val="0"/><c:holeSize val="${this.#holeSize ?? 50}"/></c:doughnutChart>`;
|
|
232
|
+
}
|
|
233
|
+
if (el === "radarChart") {
|
|
234
|
+
return `<c:radarChart><c:radarStyle val="${fam.radarStyle}"/><c:varyColors val="0"/>${this.#seriesGroupXml(indexed, fam)}${dLbls}<c:axId val="${CAT_AX_ID}"/><c:axId val="${VAL_AX_ID}"/></c:radarChart>`;
|
|
235
|
+
}
|
|
236
|
+
if (el === "scatterChart") {
|
|
237
|
+
return `<c:scatterChart><c:scatterStyle val="${fam.scatterStyle}"/><c:varyColors val="0"/>${this.#seriesGroupXml(indexed, fam)}${dLbls}<c:axId val="${CAT_AX_ID}"/><c:axId val="${VAL_AX_ID}"/></c:scatterChart>`;
|
|
238
|
+
}
|
|
239
|
+
if (el === "bubbleChart") {
|
|
240
|
+
return `<c:bubbleChart><c:varyColors val="0"/>${this.#seriesGroupXml(indexed, fam)}${dLbls}<c:bubbleScale val="100"/><c:showNegBubbles val="0"/><c:axId val="${CAT_AX_ID}"/><c:axId val="${VAL_AX_ID}"/></c:bubbleChart>`;
|
|
241
|
+
}
|
|
242
|
+
if (!this.#hasSecondary()) {
|
|
243
|
+
return this.#cartesianGroupXml(indexed, fam, CAT_AX_ID, VAL_AX_ID);
|
|
244
|
+
}
|
|
245
|
+
const primary = indexed.filter((e) => !e.s.secondaryAxis);
|
|
246
|
+
const secondary = indexed.filter((e) => e.s.secondaryAxis);
|
|
247
|
+
const secFam = resolveFamily(this.#secondaryType);
|
|
248
|
+
return this.#cartesianGroupXml(primary, fam, CAT_AX_ID, VAL_AX_ID) + this.#cartesianGroupXml(secondary, secFam, SEC_CAT_AX_ID, SEC_VAL_AX_ID);
|
|
253
249
|
}
|
|
254
|
-
|
|
255
|
-
|
|
250
|
+
#cartesianGroupXml(entries, fam, catId, valId) {
|
|
251
|
+
const el = fam.element;
|
|
252
|
+
const barDir = fam.barDir ? `<c:barDir val="${fam.barDir}"/>` : "";
|
|
253
|
+
const grouping = fam.grouping ? `<c:grouping val="${fam.grouping}"/>` : "";
|
|
254
|
+
const marker = el === "lineChart" ? `<c:marker val="${fam.markers ? 1 : 0}"/>` : "";
|
|
255
|
+
const barExtras = el === "barChart" ? `<c:gapWidth val="${this.#gapWidth}"/>${fam.overlap !== void 0 ? `<c:overlap val="${fam.overlap}"/>` : ""}` : "";
|
|
256
|
+
return `<c:${el}>${barDir}${grouping}<c:varyColors val="0"/>${this.#seriesGroupXml(entries, fam)}${this.#buildDataLabelsXml()}${barExtras}${marker}<c:axId val="${catId}"/><c:axId val="${valId}"/></c:${el}>`;
|
|
256
257
|
}
|
|
257
|
-
|
|
258
|
-
return
|
|
258
|
+
#seriesGroupXml(entries, fam) {
|
|
259
|
+
return entries.map((e) => this.#buildSeriesXml(e.s, e.idx, fam)).join("");
|
|
259
260
|
}
|
|
260
|
-
|
|
261
|
-
|
|
261
|
+
#buildSeriesXml(s, idx, fam) {
|
|
262
|
+
const tx = s.name ? `<c:tx>${this.#refOrLiteral(s.name)}</c:tx>` : "";
|
|
263
|
+
const spPr = s.color ? this.#seriesColorXml(s.color, fam) : "";
|
|
264
|
+
const dPt = s.pointColors && s.pointColors.length ? this.#buildDataPointsXml(s.pointColors, fam) : "";
|
|
265
|
+
const trend = s.trendline ? this.#buildTrendlineXml(s.trendline) : "";
|
|
266
|
+
const marker = fam.markers ? `<c:marker><c:symbol val="circle"/><c:size val="5"/></c:marker>` : "";
|
|
267
|
+
if (fam.seriesKind === "xy") {
|
|
268
|
+
const xVal = s.categories ? `<c:xVal>${numRef(s.categories)}</c:xVal>` : "";
|
|
269
|
+
const yVal = `<c:yVal>${numRef(s.values)}</c:yVal>`;
|
|
270
|
+
const smooth2 = `<c:smooth val="${fam.smooth ? 1 : 0}"/>`;
|
|
271
|
+
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/>${tx}${spPr}${marker}${dPt}${trend}${xVal}${yVal}${smooth2}</c:ser>`;
|
|
272
|
+
}
|
|
273
|
+
if (fam.seriesKind === "bubble") {
|
|
274
|
+
const xVal = s.categories ? `<c:xVal>${numRef(s.categories)}</c:xVal>` : "";
|
|
275
|
+
const yVal = `<c:yVal>${numRef(s.values)}</c:yVal>`;
|
|
276
|
+
const bub = s.bubbleSize ? `<c:bubbleSize>${numRef(s.bubbleSize)}</c:bubbleSize>` : `<c:bubbleSize><c:numLit><c:formatCode>General</c:formatCode><c:ptCount val="0"/></c:numLit></c:bubbleSize>`;
|
|
277
|
+
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/>${tx}${spPr}${dPt}${trend}${xVal}${yVal}${bub}<c:bubble3D val="0"/></c:ser>`;
|
|
278
|
+
}
|
|
279
|
+
const catMarker = fam.element === "lineChart" || fam.element === "radarChart" ? marker : "";
|
|
280
|
+
const cat = s.categories ? `<c:cat>${strRef(s.categories)}</c:cat>` : "";
|
|
281
|
+
const val = `<c:val>${numRef(s.values)}</c:val>`;
|
|
282
|
+
const smooth = fam.element === "lineChart" ? `<c:smooth val="0"/>` : "";
|
|
283
|
+
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/>${tx}${spPr}${catMarker}${dPt}${trend}${cat}${val}${smooth}</c:ser>`;
|
|
262
284
|
}
|
|
263
|
-
|
|
264
|
-
return `<c:
|
|
285
|
+
#buildDataPointsXml(colors, fam) {
|
|
286
|
+
return colors.map((c, i) => `<c:dPt><c:idx val="${i}"/><c:bubble3D val="0"/>${this.#seriesColorXml(c, fam)}</c:dPt>`).join("");
|
|
265
287
|
}
|
|
266
|
-
|
|
267
|
-
|
|
288
|
+
#buildTrendlineXml(t) {
|
|
289
|
+
const order = t.type === "poly" /* Polynomial */ ? `<c:order val="${t.order ?? 2}"/>` : "";
|
|
290
|
+
const period = t.type === "movingAvg" /* MovingAverage */ ? `<c:period val="${t.period ?? 2}"/>` : "";
|
|
291
|
+
return `<c:trendline><c:trendlineType val="${t.type}"/>` + order + period + `<c:dispRSqr val="${t.displayRSquared ? 1 : 0}"/><c:dispEq val="${t.displayEquation ? 1 : 0}"/></c:trendline>`;
|
|
268
292
|
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
return __privateMethod(this, _ExcelChart_instances, cartesianGroupXml_fn).call(this, primary, fam, CAT_AX_ID, VAL_AX_ID) + __privateMethod(this, _ExcelChart_instances, cartesianGroupXml_fn).call(this, secondary, secFam, SEC_CAT_AX_ID, SEC_VAL_AX_ID);
|
|
273
|
-
};
|
|
274
|
-
cartesianGroupXml_fn = function(entries, fam, catId, valId) {
|
|
275
|
-
const el = fam.element;
|
|
276
|
-
const barDir = fam.barDir ? `<c:barDir val="${fam.barDir}"/>` : "";
|
|
277
|
-
const grouping = fam.grouping ? `<c:grouping val="${fam.grouping}"/>` : "";
|
|
278
|
-
const marker = el === "lineChart" ? `<c:marker val="${fam.markers ? 1 : 0}"/>` : "";
|
|
279
|
-
const barExtras = el === "barChart" ? `<c:gapWidth val="${__privateGet(this, _gapWidth)}"/>${fam.overlap !== void 0 ? `<c:overlap val="${fam.overlap}"/>` : ""}` : "";
|
|
280
|
-
return `<c:${el}>${barDir}${grouping}<c:varyColors val="0"/>${__privateMethod(this, _ExcelChart_instances, seriesGroupXml_fn).call(this, entries, fam)}${__privateMethod(this, _ExcelChart_instances, buildDataLabelsXml_fn).call(this)}${barExtras}${marker}<c:axId val="${catId}"/><c:axId val="${valId}"/></c:${el}>`;
|
|
281
|
-
};
|
|
282
|
-
seriesGroupXml_fn = function(entries, fam) {
|
|
283
|
-
return entries.map((e) => __privateMethod(this, _ExcelChart_instances, buildSeriesXml_fn).call(this, e.s, e.idx, fam)).join("");
|
|
284
|
-
};
|
|
285
|
-
buildSeriesXml_fn = function(s, idx, fam) {
|
|
286
|
-
const tx = s.name ? `<c:tx>${__privateMethod(this, _ExcelChart_instances, refOrLiteral_fn).call(this, s.name)}</c:tx>` : "";
|
|
287
|
-
const spPr = s.color ? __privateMethod(this, _ExcelChart_instances, seriesColorXml_fn).call(this, s.color, fam) : "";
|
|
288
|
-
const dPt = s.pointColors && s.pointColors.length ? __privateMethod(this, _ExcelChart_instances, buildDataPointsXml_fn).call(this, s.pointColors, fam) : "";
|
|
289
|
-
const trend = s.trendline ? __privateMethod(this, _ExcelChart_instances, buildTrendlineXml_fn).call(this, s.trendline) : "";
|
|
290
|
-
const marker = fam.markers ? `<c:marker><c:symbol val="circle"/><c:size val="5"/></c:marker>` : "";
|
|
291
|
-
if (fam.seriesKind === "xy") {
|
|
292
|
-
const xVal = s.categories ? `<c:xVal>${numRef(s.categories)}</c:xVal>` : "";
|
|
293
|
-
const yVal = `<c:yVal>${numRef(s.values)}</c:yVal>`;
|
|
294
|
-
const smooth2 = `<c:smooth val="${fam.smooth ? 1 : 0}"/>`;
|
|
295
|
-
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/>${tx}${spPr}${marker}${dPt}${trend}${xVal}${yVal}${smooth2}</c:ser>`;
|
|
296
|
-
}
|
|
297
|
-
if (fam.seriesKind === "bubble") {
|
|
298
|
-
const xVal = s.categories ? `<c:xVal>${numRef(s.categories)}</c:xVal>` : "";
|
|
299
|
-
const yVal = `<c:yVal>${numRef(s.values)}</c:yVal>`;
|
|
300
|
-
const bub = s.bubbleSize ? `<c:bubbleSize>${numRef(s.bubbleSize)}</c:bubbleSize>` : `<c:bubbleSize><c:numLit><c:formatCode>General</c:formatCode><c:ptCount val="0"/></c:numLit></c:bubbleSize>`;
|
|
301
|
-
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/>${tx}${spPr}${dPt}${trend}${xVal}${yVal}${bub}<c:bubble3D val="0"/></c:ser>`;
|
|
302
|
-
}
|
|
303
|
-
const catMarker = fam.element === "lineChart" || fam.element === "radarChart" ? marker : "";
|
|
304
|
-
const cat = s.categories ? `<c:cat>${strRef(s.categories)}</c:cat>` : "";
|
|
305
|
-
const val = `<c:val>${numRef(s.values)}</c:val>`;
|
|
306
|
-
const smooth = fam.element === "lineChart" ? `<c:smooth val="0"/>` : "";
|
|
307
|
-
return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/>${tx}${spPr}${catMarker}${dPt}${trend}${cat}${val}${smooth}</c:ser>`;
|
|
308
|
-
};
|
|
309
|
-
buildDataPointsXml_fn = function(colors, fam) {
|
|
310
|
-
return colors.map((c, i) => `<c:dPt><c:idx val="${i}"/><c:bubble3D val="0"/>${__privateMethod(this, _ExcelChart_instances, seriesColorXml_fn).call(this, c, fam)}</c:dPt>`).join("");
|
|
311
|
-
};
|
|
312
|
-
buildTrendlineXml_fn = function(t) {
|
|
313
|
-
const order = t.type === "poly" /* Polynomial */ ? `<c:order val="${t.order ?? 2}"/>` : "";
|
|
314
|
-
const period = t.type === "movingAvg" /* MovingAverage */ ? `<c:period val="${t.period ?? 2}"/>` : "";
|
|
315
|
-
return `<c:trendline><c:trendlineType val="${t.type}"/>` + order + period + `<c:dispRSqr val="${t.displayRSquared ? 1 : 0}"/><c:dispEq val="${t.displayEquation ? 1 : 0}"/></c:trendline>`;
|
|
316
|
-
};
|
|
317
|
-
seriesColorXml_fn = function(color, fam) {
|
|
318
|
-
const fill = `<a:solidFill><a:srgbClr val="${toSrgb(color)}"/></a:solidFill>`;
|
|
319
|
-
return fam.colorAsLine ? `<c:spPr><a:ln w="28575">${fill}</a:ln></c:spPr>` : `<c:spPr>${fill}</c:spPr>`;
|
|
320
|
-
};
|
|
321
|
-
refOrLiteral_fn = function(name) {
|
|
322
|
-
return name.includes("!") ? strRef(name) : `<c:v>${puredocsExcel.escapeXml(name)}</c:v>`;
|
|
323
|
-
};
|
|
324
|
-
buildDataLabelsXml_fn = function() {
|
|
325
|
-
const d = __privateGet(this, _dataLabels);
|
|
326
|
-
if (!d) return "";
|
|
327
|
-
const flag = (b) => b ? 1 : 0;
|
|
328
|
-
return `<c:dLbls><c:showLegendKey val="0"/><c:showVal val="${flag(d.value)}"/><c:showCatName val="${flag(d.category)}"/><c:showSerName val="${flag(d.series)}"/><c:showPercent val="${flag(d.percent)}"/><c:showBubbleSize val="0"/></c:dLbls>`;
|
|
329
|
-
};
|
|
330
|
-
buildAxesXml_fn = function() {
|
|
331
|
-
const fam = __privateGet(this, _family);
|
|
332
|
-
if (fam.seriesKind !== "category") {
|
|
333
|
-
return __privateMethod(this, _ExcelChart_instances, buildValAx_fn).call(this, CAT_AX_ID, "b", VAL_AX_ID, __privateGet(this, _categoryAxis), {}) + __privateMethod(this, _ExcelChart_instances, buildValAx_fn).call(this, VAL_AX_ID, "l", CAT_AX_ID, __privateGet(this, _valueAxis), {});
|
|
293
|
+
#seriesColorXml(color, fam) {
|
|
294
|
+
const fill = `<a:solidFill><a:srgbClr val="${toSrgb(color)}"/></a:solidFill>`;
|
|
295
|
+
return fam.colorAsLine ? `<c:spPr><a:ln w="28575">${fill}</a:ln></c:spPr>` : `<c:spPr>${fill}</c:spPr>`;
|
|
334
296
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
297
|
+
#refOrLiteral(name) {
|
|
298
|
+
return name.includes("!") ? strRef(name) : `<c:v>${puredocsExcel.escapeXml(name)}</c:v>`;
|
|
299
|
+
}
|
|
300
|
+
#buildDataLabelsXml() {
|
|
301
|
+
const d = this.#dataLabels;
|
|
302
|
+
if (!d) return "";
|
|
303
|
+
const flag = (b) => b ? 1 : 0;
|
|
304
|
+
return `<c:dLbls><c:showLegendKey val="0"/><c:showVal val="${flag(d.value)}"/><c:showCatName val="${flag(d.category)}"/><c:showSerName val="${flag(d.series)}"/><c:showPercent val="${flag(d.percent)}"/><c:showBubbleSize val="0"/></c:dLbls>`;
|
|
305
|
+
}
|
|
306
|
+
#buildAxesXml() {
|
|
307
|
+
const fam = this.#family;
|
|
308
|
+
if (fam.seriesKind !== "category") {
|
|
309
|
+
return this.#buildValAx(CAT_AX_ID, "b", VAL_AX_ID, this.#categoryAxis, {}) + this.#buildValAx(VAL_AX_ID, "l", CAT_AX_ID, this.#valueAxis, {});
|
|
310
|
+
}
|
|
311
|
+
let out = this.#buildCatAx(CAT_AX_ID, fam.catAxPos, VAL_AX_ID, this.#categoryAxis, {}) + this.#buildValAx(VAL_AX_ID, fam.valAxPos, CAT_AX_ID, this.#valueAxis, { crossBetween: "between" });
|
|
312
|
+
if (this.#hasSecondary()) {
|
|
313
|
+
out += this.#buildValAx(SEC_VAL_AX_ID, "r", SEC_CAT_AX_ID, this.#secondaryValueAxis, { crossBetween: "between", crosses: "max" }) + this.#buildCatAx(SEC_CAT_AX_ID, fam.catAxPos, SEC_VAL_AX_ID, {}, { deleted: true });
|
|
314
|
+
}
|
|
315
|
+
return out;
|
|
316
|
+
}
|
|
317
|
+
#buildCatAx(id, pos, crossId, cfg, opts) {
|
|
318
|
+
const title = cfg.title ? this.#buildTitleXml(cfg.title) : "";
|
|
319
|
+
const numFmt = cfg.numberFormat ? `<c:numFmt formatCode="${puredocsExcel.escapeXml(cfg.numberFormat)}" sourceLinked="0"/>` : "";
|
|
320
|
+
return `<c:catAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="${opts.deleted ? 1 : 0}"/><c:axPos val="${pos}"/>` + title + numFmt + `<c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crossAx val="${crossId}"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx>`;
|
|
321
|
+
}
|
|
322
|
+
#buildValAx(id, pos, crossId, cfg, opts) {
|
|
323
|
+
const grid = cfg.majorGridlines ? `<c:majorGridlines/>` : "";
|
|
324
|
+
const title = cfg.title ? this.#buildTitleXml(cfg.title) : "";
|
|
325
|
+
const numFmt = cfg.numberFormat ? `<c:numFmt formatCode="${puredocsExcel.escapeXml(cfg.numberFormat)}" sourceLinked="0"/>` : "";
|
|
326
|
+
const scaling = `<c:scaling><c:orientation val="minMax"/>${cfg.max !== void 0 ? `<c:max val="${cfg.max}"/>` : ""}${cfg.min !== void 0 ? `<c:min val="${cfg.min}"/>` : ""}</c:scaling>`;
|
|
327
|
+
const cb = opts.crossBetween ? `<c:crossBetween val="${opts.crossBetween}"/>` : "";
|
|
328
|
+
return `<c:valAx><c:axId val="${id}"/>` + scaling + `<c:delete val="0"/><c:axPos val="${pos}"/>` + grid + title + numFmt + `<c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crossAx val="${crossId}"/><c:crosses val="${opts.crosses ?? "autoZero"}"/>` + cb + `</c:valAx>`;
|
|
329
|
+
}
|
|
330
|
+
#buildTitleXml(text) {
|
|
331
|
+
return `<c:title><c:tx><c:rich><a:bodyPr rot="0" spcFirstLastPara="1" vertOverflow="ellipsis" vert="horz" wrap="square" anchor="ctr" anchorCtr="1"/><a:lstStyle/><a:p><a:r><a:t>${puredocsExcel.escapeXml(text)}</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title>`;
|
|
338
332
|
}
|
|
339
|
-
return out;
|
|
340
|
-
};
|
|
341
|
-
buildCatAx_fn = function(id, pos, crossId, cfg, opts) {
|
|
342
|
-
const title = cfg.title ? __privateMethod(this, _ExcelChart_instances, buildTitleXml_fn).call(this, cfg.title) : "";
|
|
343
|
-
const numFmt = cfg.numberFormat ? `<c:numFmt formatCode="${puredocsExcel.escapeXml(cfg.numberFormat)}" sourceLinked="0"/>` : "";
|
|
344
|
-
return `<c:catAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:delete val="${opts.deleted ? 1 : 0}"/><c:axPos val="${pos}"/>` + title + numFmt + `<c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crossAx val="${crossId}"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx>`;
|
|
345
|
-
};
|
|
346
|
-
buildValAx_fn = function(id, pos, crossId, cfg, opts) {
|
|
347
|
-
const grid = cfg.majorGridlines ? `<c:majorGridlines/>` : "";
|
|
348
|
-
const title = cfg.title ? __privateMethod(this, _ExcelChart_instances, buildTitleXml_fn).call(this, cfg.title) : "";
|
|
349
|
-
const numFmt = cfg.numberFormat ? `<c:numFmt formatCode="${puredocsExcel.escapeXml(cfg.numberFormat)}" sourceLinked="0"/>` : "";
|
|
350
|
-
const scaling = `<c:scaling><c:orientation val="minMax"/>${cfg.max !== void 0 ? `<c:max val="${cfg.max}"/>` : ""}${cfg.min !== void 0 ? `<c:min val="${cfg.min}"/>` : ""}</c:scaling>`;
|
|
351
|
-
const cb = opts.crossBetween ? `<c:crossBetween val="${opts.crossBetween}"/>` : "";
|
|
352
|
-
return `<c:valAx><c:axId val="${id}"/>` + scaling + `<c:delete val="0"/><c:axPos val="${pos}"/>` + grid + title + numFmt + `<c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crossAx val="${crossId}"/><c:crosses val="${opts.crosses ?? "autoZero"}"/>` + cb + `</c:valAx>`;
|
|
353
|
-
};
|
|
354
|
-
buildTitleXml_fn = function(text) {
|
|
355
|
-
return `<c:title><c:tx><c:rich><a:bodyPr rot="0" spcFirstLastPara="1" vertOverflow="ellipsis" vert="horz" wrap="square" anchor="ctr" anchorCtr="1"/><a:lstStyle/><a:p><a:r><a:t>${puredocsExcel.escapeXml(text)}</a:t></a:r></a:p></c:rich></c:tx><c:overlay val="0"/></c:title>`;
|
|
356
333
|
};
|
|
357
|
-
var ExcelChart = _ExcelChart;
|
|
358
334
|
|
|
359
335
|
exports.ChartLegendPosition = ChartLegendPosition;
|
|
360
336
|
exports.ExcelChart = ExcelChart;
|