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