@opendata-ai/openchart-engine 6.28.5 → 7.0.0

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.
Files changed (48) hide show
  1. package/README.md +1 -0
  2. package/dist/index.d.ts +8 -11
  3. package/dist/index.js +12297 -11338
  4. package/dist/index.js.map +1 -1
  5. package/package.json +2 -2
  6. package/src/__test-fixtures__/specs.ts +3 -0
  7. package/src/__tests__/__snapshots__/compile-snapshot.test.ts.snap +452 -377
  8. package/src/__tests__/axes.test.ts +75 -0
  9. package/src/__tests__/compile-chart.test.ts +304 -0
  10. package/src/__tests__/dimensions.test.ts +224 -0
  11. package/src/__tests__/legend.test.ts +44 -3
  12. package/src/annotations/__tests__/compute.test.ts +111 -0
  13. package/src/annotations/__tests__/resolve-text.test.ts +288 -0
  14. package/src/annotations/constants.ts +20 -0
  15. package/src/annotations/resolve-text.ts +161 -7
  16. package/src/charts/bar/compute.ts +24 -0
  17. package/src/charts/bar/labels.ts +1 -0
  18. package/src/charts/column/compute.ts +33 -1
  19. package/src/charts/column/labels.ts +1 -0
  20. package/src/charts/dot/labels.ts +1 -0
  21. package/src/charts/line/__tests__/compute.test.ts +153 -3
  22. package/src/charts/line/area.ts +111 -23
  23. package/src/charts/line/compute.ts +40 -10
  24. package/src/charts/line/index.ts +34 -7
  25. package/src/charts/line/labels.ts +29 -0
  26. package/src/charts/pie/labels.ts +1 -0
  27. package/src/compile/layer.ts +497 -0
  28. package/src/compile.ts +211 -586
  29. package/src/compiler/__tests__/sparkline-defaults.test.ts +153 -0
  30. package/src/compiler/normalize.ts +6 -1
  31. package/src/compiler/sparkline-defaults.ts +138 -0
  32. package/src/compiler/types.ts +8 -0
  33. package/src/endpoint-labels/__tests__/compute.test.ts +438 -0
  34. package/src/endpoint-labels/compute.ts +417 -0
  35. package/src/endpoint-labels/constants.ts +54 -0
  36. package/src/endpoint-labels/format.ts +30 -0
  37. package/src/endpoint-labels/predict.ts +108 -0
  38. package/src/graphs/compile-graph.ts +1 -0
  39. package/src/layout/axes.ts +27 -2
  40. package/src/layout/dimensions.ts +270 -33
  41. package/src/layout/metrics.ts +118 -0
  42. package/src/layout/scales.ts +41 -4
  43. package/src/legend/__tests__/suppression.test.ts +294 -0
  44. package/src/legend/compute.ts +50 -40
  45. package/src/legend/suppression.ts +204 -0
  46. package/src/sankey/compile-sankey.ts +2 -0
  47. package/src/tables/__tests__/heatmap.test.ts +4 -27
  48. package/src/tables/heatmap.ts +6 -2
@@ -0,0 +1,497 @@
1
+ import type {
2
+ ChartLayout,
3
+ ChartSpec,
4
+ CompileOptions,
5
+ DataRow,
6
+ Encoding,
7
+ LayerSpec,
8
+ Mark,
9
+ } from '@opendata-ai/openchart-core';
10
+ import {
11
+ AXIS_TITLE_TRAILING_PAD,
12
+ BREAKPOINT_COMPACT_MAX,
13
+ estimateTextWidth,
14
+ getAxisTitleOffset,
15
+ resolveTheme,
16
+ TICK_LABEL_OFFSET,
17
+ } from '@opendata-ai/openchart-core';
18
+ import { format as d3Format } from 'd3-format';
19
+ import { scaleLinear } from 'd3-scale';
20
+ import { curveMonotoneX, area as d3area, line as d3line } from 'd3-shape';
21
+ import { flattenLayers } from '../compiler/index';
22
+
23
+ type ChartCompiler = (spec: unknown, options: CompileOptions) => ChartLayout;
24
+
25
+ /**
26
+ * Compile a LayerSpec into a single ChartLayout.
27
+ *
28
+ * Flattens nested layers, merges inherited data/encoding/transforms,
29
+ * compiles each leaf layer independently, unions scale domains (shared
30
+ * by default), and concatenates marks in layer order.
31
+ */
32
+ export function compileLayer(
33
+ spec: LayerSpec,
34
+ options: CompileOptions,
35
+ compileChart: ChartCompiler,
36
+ ): ChartLayout {
37
+ const leaves = flattenLayers(spec);
38
+
39
+ if (leaves.length === 0) {
40
+ throw new Error('LayerSpec has no leaf chart specs after flattening');
41
+ }
42
+
43
+ if (leaves.length === 1) {
44
+ const singleSpec = buildPrimarySpec(leaves, spec);
45
+ return compileChart(singleSpec, options);
46
+ }
47
+
48
+ if (spec.resolve?.scale?.y === 'independent') {
49
+ return compileLayerIndependent(leaves, spec, options, compileChart);
50
+ }
51
+
52
+ const primarySpec = buildPrimarySpec(leaves, spec);
53
+ const primaryLayout = compileChart(primarySpec, options);
54
+
55
+ const allMarks: Mark[] = [];
56
+ const seenLabels = new Set<string>();
57
+ const pLegend = primaryLayout.legend;
58
+ const mergedLegendEntries = 'entries' in pLegend ? [...pLegend.entries] : [];
59
+ for (const entry of mergedLegendEntries) {
60
+ seenLabels.add(entry.label);
61
+ }
62
+
63
+ const indexedLeaves = leaves.map((leaf, i) => ({
64
+ leaf,
65
+ zIndex: (leaf as ChartSpec).zIndex ?? i,
66
+ }));
67
+ indexedLeaves.sort((a, b) => a.zIndex - b.zIndex);
68
+
69
+ for (const { leaf } of indexedLeaves) {
70
+ const leafLayout = compileChart(leaf as unknown, options);
71
+
72
+ allMarks.push(...leafLayout.marks);
73
+
74
+ const leafLeg = leafLayout.legend;
75
+ if ('entries' in leafLeg) {
76
+ for (const entry of leafLeg.entries) {
77
+ if (!seenLabels.has(entry.label)) {
78
+ seenLabels.add(entry.label);
79
+ mergedLegendEntries.push(entry);
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ return {
86
+ ...primaryLayout,
87
+ marks: allMarks,
88
+ legend: {
89
+ ...primaryLayout.legend,
90
+ ...('entries' in pLegend ? { entries: mergedLegendEntries } : {}),
91
+ } as typeof primaryLayout.legend,
92
+ };
93
+ }
94
+
95
+ // ---------------------------------------------------------------------------
96
+ // Independent y-scale compilation (dual-axis charts)
97
+ // ---------------------------------------------------------------------------
98
+
99
+ function estimateYAxisLabelWidth(
100
+ data: DataRow[],
101
+ encoding: Encoding | undefined,
102
+ baseFontSize: number,
103
+ ): number {
104
+ if (!encoding?.y) return 40;
105
+ const yEnc = encoding.y;
106
+ const yField = yEnc.field;
107
+ if (!yField) return 40;
108
+
109
+ const yType = yEnc.type;
110
+ if (yType === 'nominal' || yType === 'ordinal') {
111
+ let maxWidth = 0;
112
+ for (const row of data) {
113
+ const label = String(row[yField] ?? '');
114
+ const w = estimateTextWidth(label, baseFontSize, 400);
115
+ if (w > maxWidth) maxWidth = w;
116
+ }
117
+ return maxWidth > 0 ? maxWidth + 10 : 40;
118
+ }
119
+
120
+ const yAxisFormat = (encoding.y.axis as Record<string, unknown> | undefined)?.format as
121
+ | string
122
+ | undefined;
123
+ let maxAbsVal = 0;
124
+ for (const row of data) {
125
+ const v = Number(row[yField]);
126
+ if (Number.isFinite(v) && Math.abs(v) > maxAbsVal) maxAbsVal = Math.abs(v);
127
+ }
128
+ let sampleLabel: string;
129
+ if (yAxisFormat) {
130
+ try {
131
+ const fmt = d3Format(yAxisFormat);
132
+ sampleLabel = fmt(maxAbsVal);
133
+ } catch {
134
+ sampleLabel = String(maxAbsVal);
135
+ }
136
+ } else {
137
+ if (maxAbsVal >= 1_000_000_000) sampleLabel = '1.5B';
138
+ else if (maxAbsVal >= 1_000_000) sampleLabel = '1.5M';
139
+ else if (maxAbsVal >= 1_000) sampleLabel = '1.5K';
140
+ else if (maxAbsVal >= 100) sampleLabel = '100';
141
+ else if (maxAbsVal >= 10) sampleLabel = '10';
142
+ else sampleLabel = '0.0';
143
+ }
144
+ const hasNeg = data.some((r) => Number(r[yField]) < 0);
145
+ const labelEst = (hasNeg ? '-' : '') + sampleLabel;
146
+ return estimateTextWidth(labelEst, baseFontSize, 400) + 10;
147
+ }
148
+
149
+ function compileLayerIndependent(
150
+ leaves: ChartSpec[],
151
+ layerSpec: LayerSpec,
152
+ options: CompileOptions,
153
+ compileChart: ChartCompiler,
154
+ ): ChartLayout {
155
+ if (leaves.length > 2) {
156
+ throw new Error(
157
+ 'Independent y-scales support at most 2 layers (left and right y-axis). ' +
158
+ `Got ${leaves.length} layers.`,
159
+ );
160
+ }
161
+
162
+ const leaf0 = leaves[0];
163
+ const leaf1 = leaves[1];
164
+
165
+ const xType0 = leaf0.encoding?.x?.type;
166
+ const xType1 = leaf1.encoding?.x?.type;
167
+ if (xType0 && xType1 && xType0 !== xType1) {
168
+ throw new Error(
169
+ `Dual-axis charts require matching x-field types across layers. ` +
170
+ `Layer 0 has '${xType0}', layer 1 has '${xType1}'.`,
171
+ );
172
+ }
173
+
174
+ const theme = resolveTheme(layerSpec.theme ?? leaf1.theme);
175
+ const axisFontSize = theme.fonts?.sizes?.axisTick ?? 11;
176
+ const rightAxisWidth = estimateYAxisLabelWidth(leaf1.data, leaf1.encoding, axisFontSize);
177
+ const yAxisConfig = leaf1.encoding?.y?.axis || undefined;
178
+ const hasRightAxisTitle = !!yAxisConfig?.title;
179
+ const tickExtent = TICK_LABEL_OFFSET + rightAxisWidth;
180
+ const bodyFontSize = theme.fonts?.sizes?.body ?? 13;
181
+ const axisTitleOffset = getAxisTitleOffset(options.width);
182
+ const halfGlyph = Math.ceil(bodyFontSize / 2);
183
+ const titleExtent = hasRightAxisTitle
184
+ ? axisTitleOffset +
185
+ halfGlyph +
186
+ (options.width < BREAKPOINT_COMPACT_MAX ? 0 : AXIS_TITLE_TRAILING_PAD)
187
+ : 0;
188
+ const rightReserve = Math.max(tickExtent, titleExtent);
189
+
190
+ const optionsWithReserve: CompileOptions = {
191
+ ...options,
192
+ rightAxisReserve: rightReserve,
193
+ };
194
+
195
+ const xField0 = leaf0.encoding?.x?.field;
196
+ const xField1 = leaf1.encoding?.x?.field;
197
+ const unionXValues = new Set<unknown>();
198
+ if (xField0) for (const row of leaf0.data) unionXValues.add(row[xField0]);
199
+ if (xField1) for (const row of leaf1.data) unionXValues.add(row[xField1]);
200
+
201
+ let leaf0WithUnionX = ensureXDomainCoverage(leaf0, xField0, unionXValues);
202
+ let leaf1WithUnionX = ensureXDomainCoverage(leaf1, xField1, unionXValues);
203
+
204
+ const aligned = alignYDomains(leaf0WithUnionX, leaf1WithUnionX);
205
+ if (aligned) {
206
+ leaf0WithUnionX = withYDomain(leaf0WithUnionX, aligned.domain0);
207
+ leaf1WithUnionX = withYDomain(leaf1WithUnionX, aligned.domain1);
208
+ }
209
+
210
+ const primary0 = buildPrimarySpec([leaf0WithUnionX], layerSpec);
211
+ const layout0 = compileChart(primary0, optionsWithReserve);
212
+
213
+ const primary1 = buildPrimarySpec([leaf1WithUnionX], layerSpec);
214
+ primary1.annotations = [];
215
+ const layout1 = compileChart(primary1, optionsWithReserve);
216
+
217
+ const y2Axis = layout1.axes.y
218
+ ? {
219
+ ...layout1.axes.y,
220
+ orient: 'right' as const,
221
+ gridlines: [],
222
+ start: {
223
+ x: layout0.area.x + layout0.area.width,
224
+ y: layout0.area.y,
225
+ },
226
+ end: {
227
+ x: layout0.area.x + layout0.area.width,
228
+ y: layout0.area.y + layout0.area.height,
229
+ },
230
+ }
231
+ : undefined;
232
+
233
+ const layer0HasBars = layout0.marks.some((m) => m.type === 'rect');
234
+ const layer1HasBars = layout1.marks.some((m) => m.type === 'rect');
235
+
236
+ const bandCenterByCategory = new Map<string, number>();
237
+ if (layer0HasBars && layout0.axes.x?.ticks) {
238
+ for (const tick of layout0.axes.x.ticks) {
239
+ bandCenterByCategory.set(String(tick.label), tick.position);
240
+ }
241
+ } else if (layer1HasBars && layout1.axes.x?.ticks) {
242
+ for (const tick of layout1.axes.x.ticks) {
243
+ bandCenterByCategory.set(String(tick.label), tick.position);
244
+ }
245
+ }
246
+
247
+ const remapMarkX = (xField: string | undefined, mark: Mark): Mark => {
248
+ if (!xField || bandCenterByCategory.size === 0) return mark;
249
+ if (mark.type === 'line') {
250
+ const newPoints = mark.points.map((p, i) => {
251
+ const bx = bandCenterByCategory.get(String(mark.data[i]?.[xField] ?? ''));
252
+ return bx !== undefined ? { ...p, x: bx } : p;
253
+ });
254
+ const newDataPoints = mark.dataPoints?.map((dp, i) => {
255
+ const bx = bandCenterByCategory.get(String(mark.data[i]?.[xField] ?? ''));
256
+ return bx !== undefined ? { ...dp, x: bx } : dp;
257
+ });
258
+ const newPath =
259
+ d3line<{ x: number; y: number }>()
260
+ .x((p) => p.x)
261
+ .y((p) => p.y)
262
+ .curve(curveMonotoneX)(newPoints) ?? undefined;
263
+ return { ...mark, points: newPoints, dataPoints: newDataPoints, path: newPath };
264
+ }
265
+ if (mark.type === 'area') {
266
+ const newTopPoints = mark.topPoints.map((p, i) => {
267
+ const bx = bandCenterByCategory.get(String(mark.data[i]?.[xField] ?? ''));
268
+ return bx !== undefined ? { ...p, x: bx } : p;
269
+ });
270
+ const newBottomPoints = mark.bottomPoints.map((p, i) => {
271
+ const bx = bandCenterByCategory.get(String(mark.data[i]?.[xField] ?? ''));
272
+ return bx !== undefined ? { ...p, x: bx } : p;
273
+ });
274
+ const newDataPoints = mark.dataPoints?.map((dp, i) => {
275
+ const bx = bandCenterByCategory.get(String(mark.data[i]?.[xField] ?? ''));
276
+ return bx !== undefined ? { ...dp, x: bx } : dp;
277
+ });
278
+ const areaGen = d3area<{ x: number; yTop: number; yBottom: number }>()
279
+ .x((p) => p.x)
280
+ .y0((p) => p.yBottom)
281
+ .y1((p) => p.yTop)
282
+ .curve(curveMonotoneX);
283
+ const topLineGen = d3line<{ x: number; yTop: number }>()
284
+ .x((p) => p.x)
285
+ .y((p) => p.yTop)
286
+ .curve(curveMonotoneX);
287
+ const combined = newTopPoints.map((tp, i) => ({
288
+ x: tp.x,
289
+ yTop: tp.y,
290
+ yBottom: newBottomPoints[i]?.y ?? tp.y,
291
+ }));
292
+ const newPath = areaGen(combined) ?? '';
293
+ const newTopPath = topLineGen(combined) ?? '';
294
+ return {
295
+ ...mark,
296
+ topPoints: newTopPoints,
297
+ bottomPoints: newBottomPoints,
298
+ dataPoints: newDataPoints,
299
+ path: newPath,
300
+ topPath: newTopPath,
301
+ };
302
+ }
303
+ if (mark.type === 'point') {
304
+ const bx = bandCenterByCategory.get(String(mark.data[xField] ?? ''));
305
+ return bx !== undefined ? { ...mark, cx: bx } : mark;
306
+ }
307
+ return mark;
308
+ };
309
+
310
+ const adjustedMarks0 =
311
+ bandCenterByCategory.size > 0 && !layer0HasBars
312
+ ? layout0.marks.map((m) => remapMarkX(xField0, m))
313
+ : layout0.marks;
314
+
315
+ const taggedMarks1 = layout1.marks.map((mark) => {
316
+ const tagged = { ...mark, yScale: 'y2' as const };
317
+ if (bandCenterByCategory.size > 0 && !layer1HasBars) {
318
+ return remapMarkX(xField1, tagged) as typeof tagged;
319
+ }
320
+ return tagged;
321
+ });
322
+
323
+ const seenLabels = new Set<string>();
324
+ const l0Legend = layout0.legend;
325
+ const l1Legend = layout1.legend;
326
+ const mergedLegendEntries = 'entries' in l0Legend ? [...l0Legend.entries] : [];
327
+ for (const entry of mergedLegendEntries) seenLabels.add(entry.label);
328
+ const l1Entries = 'entries' in l1Legend ? l1Legend.entries : [];
329
+ for (const entry of l1Entries) {
330
+ if (!seenLabels.has(entry.label)) {
331
+ seenLabels.add(entry.label);
332
+ mergedLegendEntries.push(entry);
333
+ }
334
+ }
335
+
336
+ const l0Count = layout0.marks.length;
337
+ const mergedTooltips = new Map(layout0.tooltipDescriptors);
338
+ for (const [key, value] of layout1.tooltipDescriptors) {
339
+ const match = /^(rect|point|arc)-(\d+)$/.exec(key);
340
+ if (match) {
341
+ const offsetKey = `${match[1]}-${Number(match[2]) + l0Count}`;
342
+ mergedTooltips.set(offsetKey, value);
343
+ } else {
344
+ mergedTooltips.set(key, value);
345
+ }
346
+ }
347
+
348
+ const z0 = leaf0.zIndex ?? 0;
349
+ const z1 = leaf1.zIndex ?? 1;
350
+ const marks =
351
+ z0 <= z1 ? [...adjustedMarks0, ...taggedMarks1] : [...taggedMarks1, ...adjustedMarks0];
352
+
353
+ return {
354
+ ...layout0,
355
+ axes: {
356
+ x: layout0.axes.x,
357
+ y: layout0.axes.y,
358
+ y2: y2Axis,
359
+ },
360
+ marks,
361
+ legend: {
362
+ ...layout0.legend,
363
+ ...('entries' in l0Legend ? { entries: mergedLegendEntries } : {}),
364
+ } as typeof layout0.legend,
365
+ tooltipDescriptors: mergedTooltips,
366
+ };
367
+ }
368
+
369
+ function ensureXDomainCoverage(
370
+ leaf: ChartSpec,
371
+ xField: string | undefined,
372
+ allXValues: Set<unknown>,
373
+ ): ChartSpec {
374
+ if (!xField || allXValues.size === 0) return leaf;
375
+
376
+ const existingXValues = new Set<unknown>();
377
+ for (const row of leaf.data) existingXValues.add(row[xField]);
378
+
379
+ const missingRows: DataRow[] = [];
380
+ for (const xVal of allXValues) {
381
+ if (!existingXValues.has(xVal)) {
382
+ missingRows.push({ [xField]: xVal });
383
+ }
384
+ }
385
+
386
+ if (missingRows.length === 0) return leaf;
387
+
388
+ return {
389
+ ...leaf,
390
+ data: [...leaf.data, ...missingRows],
391
+ };
392
+ }
393
+
394
+ function alignYDomains(
395
+ leaf0: ChartSpec,
396
+ leaf1: ChartSpec,
397
+ ): { domain0: [number, number]; domain1: [number, number] } | undefined {
398
+ const yEnc0 = leaf0.encoding?.y;
399
+ const yEnc1 = leaf1.encoding?.y;
400
+ if (!yEnc0 || !yEnc1) return undefined;
401
+ if (yEnc0.type !== 'quantitative' || yEnc1.type !== 'quantitative') return undefined;
402
+
403
+ if (yEnc0.scale?.domain || yEnc1.scale?.domain) return undefined;
404
+
405
+ const includeZero0 = yEnc0.scale?.zero !== false;
406
+ const includeZero1 = yEnc1.scale?.zero !== false;
407
+
408
+ const vals0 = leaf0.data.map((r) => Number(r[yEnc0.field])).filter(Number.isFinite);
409
+ const vals1 = leaf1.data.map((r) => Number(r[yEnc1.field])).filter(Number.isFinite);
410
+ if (vals0.length === 0 || vals1.length === 0) return undefined;
411
+
412
+ const niced = (vals: number[], includeZero: boolean): [number, number] => {
413
+ let lo = Math.min(...vals);
414
+ let hi = Math.max(...vals);
415
+ if (includeZero) {
416
+ lo = Math.min(0, lo);
417
+ hi = Math.max(0, hi);
418
+ }
419
+ const s = scaleLinear().domain([lo, hi]);
420
+ s.nice();
421
+ const [dLo, dHi] = s.domain();
422
+ return [dLo, dHi];
423
+ };
424
+
425
+ const [min0, max0] = niced(vals0, includeZero0);
426
+ const [min1, max1] = niced(vals1, includeZero1);
427
+
428
+ const span0 = max0 - min0;
429
+ const span1 = max1 - min1;
430
+ if (span0 === 0 || span1 === 0) return undefined;
431
+
432
+ const zf0 = (0 - min0) / span0;
433
+ const zf1 = (0 - min1) / span1;
434
+
435
+ const zeroInDomain0 = zf0 >= -0.001 && zf0 <= 1.001;
436
+ const zeroInDomain1 = zf1 >= -0.001 && zf1 <= 1.001;
437
+ if (!zeroInDomain0 || !zeroInDomain1) return undefined;
438
+
439
+ if (Math.abs(zf0 - zf1) < 0.001) {
440
+ return { domain0: [min0, max0], domain1: [min1, max1] };
441
+ }
442
+
443
+ const targetZf = Math.max(zf0, zf1);
444
+
445
+ const align = (dMin: number, dMax: number, currentZf: number): [number, number] => {
446
+ if (Math.abs(currentZf - targetZf) < 0.001) return [dMin, dMax];
447
+
448
+ if (targetZf > currentZf) {
449
+ const newMin = -(targetZf / (1 - targetZf)) * dMax;
450
+ return [newMin, dMax];
451
+ }
452
+ const newMax = (-dMin * (1 - targetZf)) / targetZf;
453
+ return [dMin, newMax];
454
+ };
455
+
456
+ const domain0 = align(min0, max0, zf0);
457
+ const domain1 = align(min1, max1, zf1);
458
+
459
+ return { domain0, domain1 };
460
+ }
461
+
462
+ function withYDomain(leaf: ChartSpec, domain: [number, number]): ChartSpec {
463
+ if (!leaf.encoding?.y) return leaf;
464
+ return {
465
+ ...leaf,
466
+ encoding: {
467
+ ...leaf.encoding,
468
+ y: {
469
+ ...leaf.encoding.y,
470
+ scale: {
471
+ ...leaf.encoding.y.scale,
472
+ domain,
473
+ },
474
+ },
475
+ },
476
+ } as ChartSpec;
477
+ }
478
+
479
+ function buildPrimarySpec(leaves: ChartSpec[], layerSpec: LayerSpec): ChartSpec {
480
+ const allData = leaves.flatMap((leaf) => leaf.data);
481
+
482
+ const primary = {
483
+ ...leaves[0],
484
+ data: allData,
485
+ chrome: layerSpec.chrome ?? leaves[0].chrome,
486
+ annotations: layerSpec.annotations ?? leaves[0].annotations,
487
+ labels: layerSpec.labels ?? leaves[0].labels,
488
+ legend: layerSpec.legend ?? leaves[0].legend,
489
+ responsive: layerSpec.responsive ?? leaves[0].responsive,
490
+ theme: layerSpec.theme ?? leaves[0].theme,
491
+ darkMode: layerSpec.darkMode ?? leaves[0].darkMode,
492
+ watermark: layerSpec.watermark ?? leaves[0].watermark,
493
+ hiddenSeries: layerSpec.hiddenSeries ?? leaves[0].hiddenSeries,
494
+ };
495
+
496
+ return primary;
497
+ }