@devmm/puredocs-excel-charts 1.1.1 → 1.1.3

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 CHANGED
@@ -2,14 +2,7 @@
2
2
 
3
3
  var puredocsExcel = require('@devmm/puredocs-excel');
4
4
 
5
- var __typeError = (msg) => {
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 _type, _family, _secondaryType, _anchor, _title, _series, _legend, _categoryAxis, _valueAxis, _secondaryValueAxis, _dataLabels, _gapWidth, _holeSize, _ExcelChart_instances, hasSecondary_fn, buildPlotElement_fn, cartesianGroupXml_fn, seriesGroupXml_fn, buildSeriesXml_fn, buildDataPointsXml_fn, buildTrendlineXml_fn, seriesColorXml_fn, refOrLiteral_fn, buildDataLabelsXml_fn, buildAxesXml_fn, buildCatAx_fn, buildValAx_fn, buildTitleXml_fn;
118
- var _ExcelChart = class _ExcelChart {
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
- __privateAdd(this, _ExcelChart_instances);
121
- __privateAdd(this, _type);
122
- __privateAdd(this, _family);
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 __privateGet(this, _type);
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
- __privateSet(this, _anchor, { fromCol: f.column - 1, fromRow: f.row - 1, toCol: t.column - 1, toRow: t.row - 1 });
142
+ this.#anchor = { fromCol: f.column - 1, fromRow: f.row - 1, toCol: t.column - 1, toRow: t.row - 1 };
152
143
  } else {
153
- __privateSet(this, _anchor, { fromCol: anchor.fromCol, fromRow: anchor.fromRow, toCol: anchor.toCol, toRow: anchor.toRow });
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
- __privateSet(this, _title, title);
149
+ this.#title = title;
159
150
  return this;
160
151
  }
161
152
  addSeries(series) {
162
- __privateGet(this, _series).push(series);
153
+ this.#series.push(series);
163
154
  return this;
164
155
  }
165
156
  configureLegend(fn) {
166
- fn(__privateGet(this, _legend));
157
+ fn(this.#legend);
167
158
  return this;
168
159
  }
169
160
  configureCategoryAxis(fn) {
170
- fn(__privateGet(this, _categoryAxis));
161
+ fn(this.#categoryAxis);
171
162
  return this;
172
163
  }
173
164
  configureValueAxis(fn) {
174
- fn(__privateGet(this, _valueAxis));
165
+ fn(this.#valueAxis);
175
166
  return this;
176
167
  }
177
168
  configureSecondaryValueAxis(fn) {
178
- fn(__privateGet(this, _secondaryValueAxis));
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
- __privateSet(this, _secondaryType, type);
174
+ this.#secondaryType = type;
184
175
  return this;
185
176
  }
186
177
  showDataLabels(config = { value: true }) {
187
- __privateSet(this, _dataLabels, config);
178
+ this.#dataLabels = config;
188
179
  return this;
189
180
  }
190
181
  setGapWidth(gapWidth) {
191
- __privateSet(this, _gapWidth, gapWidth);
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
- __privateSet(this, _holeSize, percent);
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 = __privateGet(this, _anchor);
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 = __privateGet(this, _title) ? `${__privateMethod(this, _ExcelChart_instances, buildTitleXml_fn).call(this, __privateGet(this, _title))}<c:autoTitleDeleted val="0"/>` : `<c:autoTitleDeleted val="1"/>`;
221
- const plot = __privateMethod(this, _ExcelChart_instances, buildPlotElement_fn).call(this);
222
- const axes = __privateGet(this, _family).hasAxes ? __privateMethod(this, _ExcelChart_instances, buildAxesXml_fn).call(this) : "";
223
- const legend = __privateGet(this, _legend).position === "none" /* None */ ? "" : `<c:legend><c:legendPos val="${__privateGet(this, _legend).position}"/><c:overlay val="0"/></c: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
- _type = new WeakMap();
228
- _family = new WeakMap();
229
- _secondaryType = new WeakMap();
230
- _anchor = new WeakMap();
231
- _title = new WeakMap();
232
- _series = new WeakMap();
233
- _legend = new WeakMap();
234
- _categoryAxis = new WeakMap();
235
- _valueAxis = new WeakMap();
236
- _secondaryValueAxis = new WeakMap();
237
- _dataLabels = new WeakMap();
238
- _gapWidth = new WeakMap();
239
- _holeSize = new WeakMap();
240
- _ExcelChart_instances = new WeakSet();
241
- // ── Chart XML ─────────────────────────────────────────────────────────────
242
- /** True when a secondary-axis combo should be emitted. */
243
- hasSecondary_fn = function() {
244
- return CARTESIAN.has(__privateGet(this, _family).element) && __privateGet(this, _series).some((s) => s.secondaryAxis);
245
- };
246
- buildPlotElement_fn = function() {
247
- const fam = __privateGet(this, _family);
248
- const el = fam.element;
249
- const indexed = __privateGet(this, _series).map((s, idx) => ({ s, idx }));
250
- const dLbls = __privateMethod(this, _ExcelChart_instances, buildDataLabelsXml_fn).call(this);
251
- if (el === "pieChart") {
252
- return `<c:pieChart><c:varyColors val="1"/>${__privateMethod(this, _ExcelChart_instances, seriesGroupXml_fn).call(this, indexed, fam)}${dLbls}<c:firstSliceAng val="0"/></c:pieChart>`;
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
- if (el === "doughnutChart") {
255
- return `<c:doughnutChart><c:varyColors val="1"/>${__privateMethod(this, _ExcelChart_instances, seriesGroupXml_fn).call(this, indexed, fam)}${dLbls}<c:firstSliceAng val="0"/><c:holeSize val="${__privateGet(this, _holeSize) ?? 50}"/></c:doughnutChart>`;
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
- if (el === "radarChart") {
258
- return `<c:radarChart><c:radarStyle val="${fam.radarStyle}"/><c:varyColors val="0"/>${__privateMethod(this, _ExcelChart_instances, seriesGroupXml_fn).call(this, indexed, fam)}${dLbls}<c:axId val="${CAT_AX_ID}"/><c:axId val="${VAL_AX_ID}"/></c:radarChart>`;
258
+ #seriesGroupXml(entries, fam) {
259
+ return entries.map((e) => this.#buildSeriesXml(e.s, e.idx, fam)).join("");
259
260
  }
260
- if (el === "scatterChart") {
261
- return `<c:scatterChart><c:scatterStyle val="${fam.scatterStyle}"/><c:varyColors val="0"/>${__privateMethod(this, _ExcelChart_instances, seriesGroupXml_fn).call(this, indexed, fam)}${dLbls}<c:axId val="${CAT_AX_ID}"/><c:axId val="${VAL_AX_ID}"/></c:scatterChart>`;
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
- if (el === "bubbleChart") {
264
- return `<c:bubbleChart><c:varyColors val="0"/>${__privateMethod(this, _ExcelChart_instances, seriesGroupXml_fn).call(this, 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>`;
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
- if (!__privateMethod(this, _ExcelChart_instances, hasSecondary_fn).call(this)) {
267
- return __privateMethod(this, _ExcelChart_instances, cartesianGroupXml_fn).call(this, indexed, fam, CAT_AX_ID, VAL_AX_ID);
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
- const primary = indexed.filter((e) => !e.s.secondaryAxis);
270
- const secondary = indexed.filter((e) => e.s.secondaryAxis);
271
- const secFam = resolveFamily(__privateGet(this, _secondaryType));
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
- let out = __privateMethod(this, _ExcelChart_instances, buildCatAx_fn).call(this, CAT_AX_ID, fam.catAxPos, VAL_AX_ID, __privateGet(this, _categoryAxis), {}) + __privateMethod(this, _ExcelChart_instances, buildValAx_fn).call(this, VAL_AX_ID, fam.valAxPos, CAT_AX_ID, __privateGet(this, _valueAxis), { crossBetween: "between" });
336
- if (__privateMethod(this, _ExcelChart_instances, hasSecondary_fn).call(this)) {
337
- out += __privateMethod(this, _ExcelChart_instances, buildValAx_fn).call(this, SEC_VAL_AX_ID, "r", SEC_CAT_AX_ID, __privateGet(this, _secondaryValueAxis), { crossBetween: "between", crosses: "max" }) + __privateMethod(this, _ExcelChart_instances, buildCatAx_fn).call(this, SEC_CAT_AX_ID, fam.catAxPos, SEC_VAL_AX_ID, {}, { deleted: true });
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;