-
-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathchart-clone.ts
More file actions
3192 lines (3102 loc) · 155 KB
/
chart-clone.ts
File metadata and controls
3192 lines (3102 loc) · 155 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ── Chart Clone ──────────────────────────────────────────────────────
// Bridges the read-side `Chart` metadata produced by `parseChart` to the
// write-side `SheetChart` shape consumed by `writeXlsx`.
//
// Use case (issue #136): a template workbook stores one of each chart
// flavor; at export time the caller pulls a chart out, swaps its data
// ranges and labels, and re-emits it (often several times) into a new
// workbook. The two type families overlap — `ChartSeriesInfo` already
// mirrors `ChartSeries` — but the read side has no anchor and supports
// kinds the write side cannot author yet, so a dedicated converter
// keeps the type-narrowing explicit.
import type {
Chart,
ChartAxisCrossBetween,
ChartAxisCrosses,
ChartAxisDispUnit,
ChartAxisDispUnits,
ChartAxisGridlines,
ChartAxisLabelAlign,
ChartAxisNumberFormat,
ChartAxisScale,
ChartAxisTickLabelPosition,
ChartAxisTickMark,
ChartBorderDash,
ChartDataLabels,
ChartDataPoint,
ChartDataTable,
ChartDisplayBlanksAs,
ChartErrorBars,
ChartKind,
ChartLegendEntry,
ChartLineStroke,
ChartManualLayout,
ChartMarker,
ChartProtection,
ChartScatterStyle,
ChartSeries,
ChartShape3D,
ChartTrendline,
ChartView3D,
SheetChart,
WriteChartKind,
} from "../_types"
import { resolveBorderDash, resolveBorderWidthPt } from "./chart/shape"
import {
resolveBackWallThickness,
resolveFloorThickness,
resolveSideWallThickness,
resolveView3D,
} from "./chart/walls"
import {
resolveCloneTitleBold,
resolveCloneTitleBorderColor,
resolveCloneTitleBorderWidth,
resolveCloneTitleColor,
resolveCloneTitleFillColor,
resolveCloneTitleFontFamily,
resolveCloneTitleFontSize,
resolveCloneTitleItalic,
resolveCloneTitleLayout,
resolveCloneTitleOverlay,
resolveCloneTitleRotation,
resolveCloneTitleStrike,
resolveCloneTitleUnderline,
} from "./chart/title"
import {
resolveCloneLegendBold,
resolveCloneLegendBorderColor,
resolveCloneLegendBorderWidth,
resolveCloneLegendEntries,
resolveCloneLegendFillColor,
resolveCloneLegendFontColor,
resolveCloneLegendFontFamily,
resolveCloneLegendFontSize,
resolveCloneLegendItalic,
resolveCloneLegendLayout,
resolveCloneLegendOverlay,
resolveCloneLegendStrikethrough,
resolveCloneLegendUnderline,
} from "./chart/legend"
import { buildSeriesFromSource, resolveShowLineMarkers } from "./chart/series"
import { resolveAxes, resolveCloneAutoTitleDeleted } from "./chart/axis"
import {
resolveCloneDropLines,
resolveCloneHiLowLines,
resolveClonePlotAreaBorderColor,
resolveClonePlotAreaBorderWidth,
resolveClonePlotAreaFillColor,
resolveClonePlotAreaLayout,
resolveCloneScatterStyle,
resolveCloneSerLines,
resolveCloneUpDownBars,
resolveCloneUpDownBarsGapWidth,
resolveCloneVaryColors,
} from "./chart/plotArea"
import { resolveCloneDataTable } from "./chart/dataTable"
import { resolveChartDataLabels } from "./chart/dataLabels"
import {
resolveCloneChartSpaceBorderColor,
resolveCloneChartSpaceFillColor,
resolveCloneDate1904,
resolveCloneDispBlanksAs,
resolveCloneLang,
resolveClonePlotVisOnly,
resolveCloneProtection,
resolveCloneRoundedCorners,
resolveCloneShowDLblsOverMax,
resolveCloneStyle,
} from "./chart/chartSpace"
// ── Public API ───────────────────────────────────────────────────────
/**
* Per-series override applied on top of the source chart's series.
*
* Each field defaults to the value carried by the source series at the
* matching position. Pass `null` to drop the source value entirely
* (e.g. `color: null` removes a series tint inherited from the
* template).
*/
export interface CloneChartSeriesOverride {
name?: string | null
/** A1 range for `<c:val>` / `<c:yVal>`. Required when the source has none. */
values?: string
/** A1 range for `<c:cat>` / `<c:xVal>`. */
categories?: string | null
/** 6-digit RGB hex (e.g. `"1F77B4"`). */
color?: string | null
/**
* Per-series data label override. `undefined` (or omitted) inherits
* the source series' `dataLabels`; `null` drops the inherited block;
* `false` suppresses labels for this series alone (overriding any
* chart-level default); a `ChartDataLabels` object replaces the
* inherited block wholesale.
*/
dataLabels?: ChartDataLabels | false | null
/**
* Smoothed-line override. `undefined` (or omitted) inherits the source
* series' `smooth`; `null` drops the inherited flag (the cloned series
* renders straight); a `boolean` replaces it wholesale. Only meaningful
* for `line` and `scatter` clones — silently dropped from the output
* when the resolved chart type is anything else.
*/
smooth?: boolean | null
/**
* Line stroke override. `undefined` (or omitted) inherits the source
* series' `stroke`; `null` drops the inherited block (the cloned
* series falls back to Excel's per-series default); a
* {@link ChartLineStroke} object replaces the inherited block
* wholesale (no per-field merge — pass the full shape you want).
* Only meaningful for `line` and `scatter` clones — silently dropped
* from the output when the resolved chart type is anything else.
*/
stroke?: ChartLineStroke | null
/**
* Marker override. `undefined` (or omitted) inherits the source
* series' `marker`; `null` drops the inherited block (the cloned
* series falls back to Excel's series-rotation default); a
* {@link ChartMarker} object replaces the inherited block wholesale
* (no per-field merging — pass every field you want preserved).
* Only meaningful for `line` and `scatter` clones — silently dropped
* from the output when the resolved chart type is anything else.
*/
marker?: ChartMarker | null
/**
* Invert-if-negative override. `undefined` (or omitted) inherits the
* source series' `invertIfNegative`; `null` drops the inherited flag
* (the cloned series renders negatives in the series fill color);
* a `boolean` replaces it wholesale. Only meaningful for `bar` and
* `column` clones — silently dropped from the output when the
* resolved chart type is anything else.
*/
invertIfNegative?: boolean | null
/**
* Slice-explosion override (in percent of the radius). `undefined`
* (or omitted) inherits the source series' `explosion`; `null` drops
* the inherited value (the cloned series falls back to the OOXML
* default `0`); a finite `number` replaces it wholesale (clamped to
* the 0..400% band Excel's UI exposes; `0` collapses to absence).
* Only meaningful for `pie` and `doughnut` clones — silently dropped
* from the output when the resolved chart type is anything else.
*/
explosion?: number | null
/**
* Per-data-point override array. `undefined` inherits the source
* series' `dataPoints`; `null` drops them; an array replaces.
*/
dataPoints?: ChartDataPoint[] | null
/**
* Per-series trendline override array. `undefined` inherits the
* source series' `trendlines`; `null` drops them; an array replaces.
* Silently dropped on pie / doughnut clones.
*/
trendlines?: ChartTrendline[] | null
/**
* Per-series error-bar override array. `undefined` inherits the
* source series' `errorBars`; `null` drops them; an array replaces.
* Silently dropped on pie / doughnut clones.
*/
errorBars?: ChartErrorBars[] | null
/**
* Bubble-size A1 range override. `undefined` inherits the source
* series' parsed `bubbleSizeRef`; `null` drops it; a string replaces.
* Silently dropped on every family except `bubble`.
*/
bubbleSize?: string | null
/**
* 3D shape variant override. `undefined` inherits the source series'
* `shape3D`; `null` drops it; a {@link ChartShape3D} replaces.
* Silently dropped on every family except `bar3D`.
*/
shape3D?: ChartShape3D | null
}
/**
* Options accepted by {@link cloneChart}.
*
* `anchor` is required because the read-side `Chart` does not capture
* placement — drawings live in a separate part. Every other field
* defaults to the source chart.
*/
export interface CloneChartOptions {
/**
* Cell anchor for the cloned chart. `to` defaults to a 6×15 area
* below `from`, mirroring `SheetChart.anchor`.
*/
anchor: SheetChart["anchor"]
/**
* Override the chart family. When omitted, the source's first
* write-compatible kind is used. An explicit value lets callers
* narrow a combo chart down to one renderable type or flatten a
* `doughnut` template into a plain `pie`.
*/
type?: WriteChartKind
/** Override the chart title. Pass `null` to drop the source title. */
title?: string | null
/** Replace the entire series array (skips per-series merging). */
series?: ChartSeries[]
/**
* Per-series overrides. Indices line up with the source's
* {@link Chart.series}. Use this to remap data ranges without
* rewriting every other field.
*/
seriesOverrides?: ReadonlyArray<CloneChartSeriesOverride | undefined>
/** Override `SheetChart.legend`. */
legend?: SheetChart["legend"]
/**
* Override the chart-level legend-overlay flag. `undefined` (or
* omitted) inherits the source's parsed value; `null` drops the
* inherited value (the writer falls back to the OOXML `false` default
* — the legend reserves its own slot, no overlap with the plot area);
* a `boolean` replaces it.
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved legend is `false` (no legend element will be emitted)
* — there is no overlay flag to set on a hidden legend, so leaking
* the value into the output would carry a toggle Excel never reads.
*/
legendOverlay?: boolean | null
/**
* Override the chart-level per-series legend-entry overrides.
* `undefined` (or omitted) inherits the source's parsed list; `null`
* drops every inherited entry (the writer emits no `<c:legendEntry>`
* children); a `ChartLegendEntry[]` replaces the inherited list
* outright.
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved legend is `false` (no `<c:legend>` element will be
* emitted) — there is no slot to host the entries on a hidden legend,
* so leaking the value into the output would carry a list Excel never
* reads.
*
* Replacement semantics matter when the cloned chart's series count
* differs from the source's: an entry whose `idx` no longer points
* at a real series still emits — Excel renders it harmlessly — but a
* caller can pass `null` (or an empty array) to start fresh.
*/
legendEntries?: ChartLegendEntry[] | null
/**
* Override `SheetChart.legendFontSize`. `undefined` (or omitted)
* inherits the source's parsed `legendFontSize`; `null` drops the
* inherited size (the writer emits no `<c:txPr>` block on the
* legend, falling back to Excel's theme-default 9pt); a number
* replaces. Out-of-range / non-numeric / non-finite overrides
* collapse to `undefined` (inherit) so a typed escape from an
* untyped caller cannot pin a value the writer would silently elide
* back to absence. Fractional inputs round to the nearest 0.5pt
* (Excel's UI granularity).
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved legend is `false` (no `<c:legend>` element will be
* emitted) — there is no `<c:txPr>` slot to host the size on a
* hidden legend, so leaking the value into the output would carry a
* pin Excel never reads.
*
* The grammar mirrors `titleFontSize` / `axes.x.axisTitleFontSize` /
* `axes.x.labelFontSize` so the typography knobs compose the same way
* at the call site. Bridges another typography-customization gap for
* the dashboard composition flow tracked in #136 — a templated
* dashboard chart whose user pinned a custom legend size now
* round-trips that pin through the parse / clone / write loop.
*/
legendFontSize?: number | null
/**
* Override `SheetChart.legendBold`. `undefined` (or omitted) inherits
* the source's parsed `legendBold`; `null` drops the inherited flag
* (the writer emits no `<c:txPr>` block on the legend, falling back
* to the OOXML default — no `b` attribute, equivalent to non-bold);
* a `boolean` replaces. Non-boolean overrides (typed escapes from an
* untyped caller) collapse to `undefined` so a typed escape cannot
* pin a value the writer would silently elide.
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved legend is `false` (no `<c:legend>` element will be
* emitted) — there is no `<c:txPr>` slot to host the flag on a
* hidden legend, so leaking the value into the output would carry a
* pin Excel never reads.
*
* The grammar mirrors `titleBold` / `axes.x.axisTitleBold` /
* `axes.x.labelBold` so the typography knobs compose the same way
* at the call site. Bridges another typography-customization gap
* for the dashboard composition flow tracked in #136 — a templated
* dashboard chart whose user pinned a custom legend bold flag now
* round-trips that pin through the parse / clone / write loop.
*/
legendBold?: boolean | null
/**
* Override `SheetChart.legendItalic`. `undefined` (or omitted)
* inherits the source's parsed `legendItalic`; `null` drops the
* inherited flag (the writer emits no `<c:txPr>` block on the
* legend, falling back to the OOXML default — no `i` attribute,
* equivalent to non-italic); a `boolean` replaces. Non-boolean
* overrides (typed escapes from an untyped caller) collapse to
* `undefined` so a typed escape cannot pin a value the writer
* would silently elide.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved legend is `false` (no `<c:legend>` element will
* be emitted) — there is no `<c:txPr>` slot to host the flag on a
* hidden legend, so leaking the value into the output would carry
* a pin Excel never reads.
*
* The grammar mirrors `titleItalic` / `axes.x.axisTitleItalic` /
* `axes.x.labelItalic` so the typography knobs compose the same way
* at the call site. Bridges another typography-customization gap
* for the dashboard composition flow tracked in #136 — a templated
* dashboard chart whose user pinned a custom legend italic flag now
* round-trips that pin through the parse / clone / write loop.
*/
legendItalic?: boolean | null
/**
* Override `SheetChart.legendUnderline`. `undefined` (or omitted)
* inherits the source's parsed `legendUnderline`; `null` drops the
* inherited flag (the writer emits no `u` attribute on the legend's
* `<a:defRPr>`, falling back to the OOXML default — non-underlined);
* a `boolean` replaces. Non-boolean overrides (typed escapes from an
* untyped caller) collapse to `undefined` so a typed escape cannot
* pin a value the writer would silently elide.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved legend is `false` (no `<c:legend>` element will
* be emitted) — there is no `<c:txPr>` slot to host the flag on a
* hidden legend, so leaking the value into the output would carry
* a pin Excel never reads.
*
* The grammar mirrors `titleUnderline` /
* `axes.x.axisTitleUnderline` / `axes.x.labelUnderline` so the
* typography knobs compose the same way at the call site.
*/
legendUnderline?: boolean | null
/**
* Override `SheetChart.legendStrikethrough`. `undefined` (or omitted)
* inherits the source's parsed `legendStrikethrough`; `null` drops
* the inherited flag (the writer emits no `strike` attribute on the
* legend's `<a:defRPr>`, falling back to the OOXML default — no
* strikethrough); a `boolean` replaces. Non-boolean overrides (typed
* escapes from an untyped caller) collapse to `undefined` so a typed
* escape cannot pin a value the writer would silently elide.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved legend is `false` (no `<c:legend>` element will
* be emitted) — there is no `<c:txPr>` slot to host the flag on a
* hidden legend, so leaking the value into the output would carry
* a pin Excel never reads.
*
* The grammar mirrors `titleStrikethrough` /
* `axes.x.axisTitleStrike` / `axes.x.labelStrikethrough` so the
* typography knobs compose the same way at the call site.
*/
legendStrikethrough?: boolean | null
/**
* Override `SheetChart.legendFontColor`. `undefined` (or omitted)
* inherits the source's parsed `legendFontColor`; `null` drops the
* inherited fill (the writer emits no `<a:solidFill>` block on the
* legend's `<a:defRPr>`, falling back to the theme text color); a
* hex string replaces. Accepts the color either with or without a
* leading `#` and in any case (`"FF0000"`, `"#FF0000"`, `"ff0000"`
* all collapse to the OOXML uppercase canonical form `"FF0000"`);
* malformed inputs (wrong length, non-hex characters, alpha-channel
* forms, non-string escapes from an untyped caller) collapse to
* `undefined` so a typed escape cannot pin a value the writer would
* silently elide.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved legend is `false` (no `<c:legend>` element will
* be emitted) — there is no `<c:txPr>` slot to host the fill on a
* hidden legend, so leaking the value into the output would carry
* a pin Excel never reads.
*
* The grammar mirrors `titleColor` / `axes.x.axisTitleColor` /
* `axes.x.labelColor` so the typography knobs compose the same way
* at the call site.
*/
legendFontColor?: string | null
/**
* Override `SheetChart.legendFontFamily`. `undefined` (or omitted)
* inherits the source's parsed `legendFontFamily`; `null` drops the
* inherited typeface (the writer emits no `<a:latin>` element on
* the legend's `<a:defRPr>`, falling back to the theme typeface);
* a non-empty string replaces it. The override is trimmed; empty /
* whitespace-only strings and non-string overrides (typed escapes
* from an untyped caller) collapse to `undefined` so the cloned
* `SheetChart` always carries a value the writer will accept.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved legend is `false` (no `<c:legend>` element will
* be emitted) — there is no `<c:txPr>` slot to host the typeface on
* a hidden legend, so leaking the value into the output would carry
* a pin Excel never reads.
*
* The grammar mirrors `titleFontFamily` /
* `axes.x.axisTitleFontFamily` / `axes.x.labelFontFamily` so the
* typography knobs compose the same way at the call site.
*/
legendFontFamily?: string | null
/**
* Override `SheetChart.legendLayout`. `undefined` (or omitted)
* inherits the source's parsed `legendLayout`; `null` drops the
* inherited layout (the writer emits no `<c:layout>` block on the
* legend, falling back to Excel's auto-layout position); a
* {@link ChartManualLayout} replaces it.
*
* Each of {@link ChartManualLayout.x} / {@link ChartManualLayout.y} /
* {@link ChartManualLayout.w} / {@link ChartManualLayout.h} runs
* through the writer-side normalizer — coordinates outside the
* `0..1` band, `NaN`, `Infinity`, and non-numeric overrides all
* collapse to omitting the matching `<c:x>` / `<c:y>` / `<c:w>` /
* `<c:h>` slot so the cloned `SheetChart` always carries a value the
* writer will accept. An override whose every coordinate dropped on
* normalization collapses the entire layout to `undefined` so the
* writer skips the `<c:layout>` block entirely.
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved legend is `false` (no `<c:legend>` element will be
* emitted) — there is no slot to host the layout on a hidden legend,
* so leaking the value into the output would carry a pin Excel never
* reads. The grammar mirrors `legendOverlay` / `legendEntries` /
* `legendFontSize` so the legend knobs compose the same way at the
* call site.
*/
legendLayout?: ChartManualLayout | null
/**
* Override `SheetChart.legendFillColor`. `undefined` (or omitted)
* inherits the source's parsed `legendFillColor`; `null` drops the
* inherited fill (the writer emits no `<c:spPr>` block on
* `<c:legend>`, falling back to the theme default — typically a
* transparent background); a hex string replaces it. The override
* is normalized through the writer-side hex-color path — accepts
* `"FFFF00"` / `"#FFFF00"` / `"ffff00"` and collapses malformed
* tokens (wrong length, non-hex characters, alpha-channel forms,
* empty / whitespace-only strings, non-string escapes from an
* untyped caller) to `undefined`. The cloned `SheetChart` always
* carries a value the writer will accept; malformed source values
* likewise collapse on the resolver path.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved legend is `false` (no `<c:legend>` element will
* be emitted) — there is no slot to host the fill on a hidden
* legend, so leaking the value into the output would carry a pin
* Excel never reads.
*
* The grammar mirrors `plotAreaFillColor` / `titleColor` /
* `axes.x.axisTitleColor` / `axes.x.labelColor` /
* `legendFontColor` so the fill / color knobs compose the same way
* at the call site. The override lands on the legend's `<c:spPr>`
* block and composes independently with `legendFontColor` (which
* lands on the legend's `<c:txPr>` block) — the two knobs target
* different children of `<c:legend>` so a caller can pin both
* without conflict.
*/
legendFillColor?: string | null
/**
* Override `SheetChart.legendBorderColor`. `undefined` (or omitted)
* inherits the source's parsed `legendBorderColor`; `null` drops the
* inherited stroke (the writer falls back to the auto-stroke Excel
* picks from the chart's theme — no `<a:ln>` block on the legend's
* `<c:spPr>`); a 6-digit RGB hex string replaces it.
*
* The override runs through the same sRGB normalizer as the writer —
* the leading `#` and case are accepted, then the value collapses to
* the OOXML canonical uppercase form. Malformed tokens (wrong length,
* non-hex characters, alpha-channel forms, non-string escapes from
* an untyped caller) collapse to `undefined` so the cloned
* `SheetChart` drops the field rather than carry a value the writer
* would silently elide back to absence.
*
* The grammar mirrors `legendFillColor` so the legend `<c:spPr>`
* knobs compose the same way at the call site. Composes
* independently with `legendFillColor` — the two knobs land on the
* same `<c:spPr>` block but on different children (`<a:solidFill>`
* for fill, `<a:ln>` for stroke), and the writer emits `<c:spPr>`
* whenever either knob is set. The override is silently dropped from
* the cloned `SheetChart` when the resolved legend is `false` (no
* `<c:legend>` element will be emitted) — there is no slot to host
* the stroke on a hidden legend.
*/
legendBorderColor?: string | null
/**
* Override `SheetChart.legendBorderWidth`. `undefined` (or omitted)
* inherits the source's parsed `legendBorderWidth`; `null` drops the
* inherited width (the writer emits `<a:ln>` without a `w` attribute,
* the line keeps Excel's auto-thickness — typically 0.75 pt); a
* finite point value (e.g. `1.5`) replaces it.
*
* The override runs through the same clamp / snap as the writer —
* values are clamped to the `0.25..13.5` pt band Excel's UI exposes
* and snapped to the 0.25 pt grid so a parsed-then-written width does
* not drift across round-trips. Non-finite / non-numeric tokens
* (`NaN`, `Infinity`, strings, `null` from an untyped caller) collapse
* to `undefined` so the cloned `SheetChart` drops the field rather
* than carry a value the writer would silently elide back to absence.
*
* Composes independently with `legendBorderColor` — both knobs land
* on the same `<a:ln>` element but on a different slot (the color's
* `<a:solidFill>` child versus the line's `w` attribute). A caller
* can pin a width without a color (the border picks Excel's
* auto-color), pin a color without a width (the border picks Excel's
* auto-thickness), or pin both. The override is silently dropped from
* the cloned `SheetChart` when the resolved legend is `false` (no
* `<c:legend>` element will be emitted) — there is no slot to host
* the stroke on a hidden legend. Mirrors `plotAreaBorderWidth` —
* same accept-finite-number / clamp / snap grammar — but on the
* legend's own `<c:spPr>` block.
*/
legendBorderWidth?: number | null
/**
* Override `SheetChart.legendBorderDash`. `undefined` (or omitted)
* inherits the source's parsed dash; `null` drops the inherited
* dash (the writer renders solid); a {@link ChartBorderDash} value
* replaces it.
*
* Composes independently with `legendBorderColor` and
* `legendBorderWidth`. Silently dropped from the cloned `SheetChart`
* when the resolved legend is `false`.
*/
legendBorderDash?: ChartBorderDash | null
/**
* Override `SheetChart.plotAreaLayout`. `undefined` (or omitted)
* inherits the source's parsed `plotAreaLayout`; `null` drops the
* inherited layout (the writer emits the bare `<c:layout/>`
* placeholder, falling back to Excel's auto-layout position); a
* {@link ChartManualLayout} replaces it.
*
* Each of {@link ChartManualLayout.x} / {@link ChartManualLayout.y} /
* {@link ChartManualLayout.w} / {@link ChartManualLayout.h} runs
* through the writer-side normalizer — coordinates outside the
* `0..1` band, `NaN`, `Infinity`, and non-numeric overrides all
* collapse to omitting the matching `<c:x>` / `<c:y>` / `<c:w>` /
* `<c:h>` slot so the cloned `SheetChart` always carries a value the
* writer will accept. An override whose every coordinate dropped on
* normalization collapses the entire layout to `undefined` so the
* writer emits the bare `<c:layout/>` placeholder.
*
* The grammar mirrors `legendLayout` so the manual-layout knobs
* compose the same way at the call site. Unlike `legendLayout`, the
* plot-area layout is never gated on a visibility flag — every chart
* has a `<c:plotArea>` element to host the layout.
*/
plotAreaLayout?: ChartManualLayout | null
/**
* Override `SheetChart.plotAreaFillColor`. `undefined` (or omitted)
* inherits the source's parsed `plotAreaFillColor`; `null` drops the
* inherited fill (the writer falls back to the auto-fill Excel picks
* from the chart's theme — no `<c:spPr>` block on the plot area); a
* 6-digit RGB hex string replaces it.
*
* The override runs through the same sRGB normalizer as the writer —
* the leading `#` and case are accepted, then the value collapses to
* the OOXML canonical uppercase form. Malformed tokens (wrong length,
* non-hex characters, alpha-channel forms, non-string escapes from
* an untyped caller) collapse to `undefined` so the cloned
* `SheetChart` drops the field rather than carry a value the writer
* would silently elide back to absence.
*
* The grammar mirrors `titleColor` / `axes.x.axisTitleColor` /
* `axes.x.labelColor` so the chart `<a:srgbClr>` knobs compose the
* same way at the call site. Unlike the title / axis-title color
* knobs, the plot-area fill is never gated on a visibility flag —
* every chart has a `<c:plotArea>` element to host the fill.
*/
plotAreaFillColor?: string | null
/**
* Override `SheetChart.plotAreaBorderColor`. `undefined` (or omitted)
* inherits the source's parsed `plotAreaBorderColor`; `null` drops
* the inherited stroke (the writer falls back to the auto-stroke
* Excel picks from the chart's theme — no `<a:ln>` block on the plot
* area's `<c:spPr>`); a 6-digit RGB hex string replaces it.
*
* The override runs through the same sRGB normalizer as the writer —
* the leading `#` and case are accepted, then the value collapses to
* the OOXML canonical uppercase form. Malformed tokens (wrong length,
* non-hex characters, alpha-channel forms, non-string escapes from
* an untyped caller) collapse to `undefined` so the cloned
* `SheetChart` drops the field rather than carry a value the writer
* would silently elide back to absence.
*
* The grammar mirrors `plotAreaFillColor` so the chart `<c:spPr>`
* knobs compose the same way at the call site. Composes
* independently with `plotAreaFillColor` — the two knobs land on
* the same `<c:spPr>` block but on different children
* (`<a:solidFill>` for fill, `<a:ln>` for stroke), and the writer
* emits `<c:spPr>` whenever either knob is set. Like the fill knob,
* the border is never gated on a visibility flag — every chart has
* a `<c:plotArea>` element to host the stroke.
*/
plotAreaBorderColor?: string | null
/**
* Override `SheetChart.plotAreaBorderWidth`. `undefined` (or omitted)
* inherits the source's parsed `plotAreaBorderWidth`; `null` drops
* the inherited width (the writer emits `<a:ln>` without a `w`
* attribute, the line keeps Excel's auto-thickness — typically
* 0.75 pt); a finite point value (e.g. `1.5`) replaces it.
*
* The override runs through the same clamp / snap as the writer —
* values are clamped to the `0.25..13.5` pt band Excel's UI exposes
* and snapped to the 0.25 pt grid so a parsed-then-written width does
* not drift across round-trips. Non-finite / non-numeric tokens
* (`NaN`, `Infinity`, strings, `null` from an untyped caller) collapse
* to `undefined` so the cloned `SheetChart` drops the field rather
* than carry a value the writer would silently elide back to absence.
*
* Composes independently with `plotAreaBorderColor` — both knobs land
* on the same `<a:ln>` element but on a different slot (the color's
* `<a:solidFill>` child versus the line's `w` attribute). A caller
* can pin a width without a color (the border picks Excel's
* auto-color), pin a color without a width (the border picks Excel's
* auto-thickness), or pin both. Like the color knob, the width is
* never gated on a visibility flag — every chart has a `<c:plotArea>`
* element to host the stroke.
*/
plotAreaBorderWidth?: number | null
/**
* Override `SheetChart.plotAreaBorderDash`. `undefined` (or omitted)
* inherits the source's parsed dash; `null` drops the inherited
* dash (the writer renders solid); a {@link ChartBorderDash} value
* replaces it. Unrecognized tokens (and the OOXML default `"solid"`)
* collapse to `undefined` so the cloned `SheetChart` drops the field.
*
* Composes independently with `plotAreaBorderColor` and
* `plotAreaBorderWidth` — all three knobs share the same `<a:ln>`
* element. Like the color / width knobs, the dash is never gated on
* a visibility flag — every chart has a `<c:plotArea>` element.
*/
plotAreaBorderDash?: ChartBorderDash | null
/**
* Override `SheetChart.chartSpaceFillColor`. `undefined` (or omitted)
* inherits the source's parsed `chartSpaceFillColor`; `null` drops
* the inherited fill (the writer emits no `<c:spPr>` block on
* `<c:chartSpace>`, falling back to the auto-fill Excel picks from
* the workbook theme — typically opaque white); a 6-digit RGB hex
* string replaces it.
*
* The override runs through the same sRGB normalizer as the writer —
* the leading `#` and case are accepted, then the value collapses to
* the OOXML canonical uppercase form. Malformed tokens (wrong length,
* non-hex characters, alpha-channel forms, non-string escapes from
* an untyped caller) collapse to `undefined` so the cloned
* `SheetChart` drops the field rather than carry a value the writer
* would silently elide back to absence.
*
* The grammar mirrors `plotAreaFillColor` / `legendFillColor` /
* `titleColor` so the chart `<a:srgbClr>` fill / color knobs compose
* the same way at the call site. Unlike the title / legend color
* knobs, the chart-space fill is never gated on a visibility flag —
* every chart has a `<c:chartSpace>` document root to host the fill.
* Composes independently with `plotAreaFillColor` — the two knobs
* land on different host elements (`<c:chartSpace>` for the entire
* frame, `<c:plotArea>` for the inner band that hosts the series),
* so a caller can pin both without conflict.
*/
chartSpaceFillColor?: string | null
/**
* Override `SheetChart.chartSpaceBorderColor`. `undefined` (or
* omitted) inherits the source's parsed `chartSpaceBorderColor`;
* `null` drops the inherited stroke (the writer emits no `<a:ln>`
* block on `<c:chartSpace>`'s `<c:spPr>`, falling back to the auto-
* stroke Excel picks from the workbook theme — typically a
* translucent gray border or no border depending on the theme); a
* 6-digit RGB hex string replaces it.
*
* The override runs through the same sRGB normalizer as the writer —
* the leading `#` and case are accepted, then the value collapses to
* the OOXML canonical uppercase form. Malformed tokens (wrong length,
* non-hex characters, alpha-channel forms, non-string escapes from
* an untyped caller) collapse to `undefined` so the cloned
* `SheetChart` drops the field rather than carry a value the writer
* would silently elide back to absence.
*
* Composes independently with `chartSpaceFillColor` — the two knobs
* land on the same `<c:spPr>` block but on different children
* (`<a:solidFill>` for fill, `<a:ln>` for stroke), and the writer
* emits `<c:spPr>` whenever either knob is set. Like the fill knob,
* the border is never gated on a visibility flag — every chart has
* a `<c:chartSpace>` document root to host the stroke.
*/
chartSpaceBorderColor?: string | null
/**
* Override `SheetChart.chartSpaceBorderWidth`. `undefined` (or
* omitted) inherits the source's parsed width; `null` drops the
* inherited width (the writer emits `<a:ln>` without a `w` attribute,
* the line keeps Excel's auto-thickness — typically 0.75 pt); a
* finite point value (e.g. `1.5`) replaces it. Values are clamped
* to the `0.25..13.5` pt band Excel's UI exposes and snapped to the
* 0.25 pt grid; non-finite / non-numeric overrides collapse to
* `undefined`. Composes independently with `chartSpaceBorderColor`
* and `chartSpaceBorderDash` — all three knobs share the same
* `<a:ln>` element.
*/
chartSpaceBorderWidth?: number | null
/**
* Override `SheetChart.chartSpaceBorderDash`. `undefined` (or
* omitted) inherits the source's parsed dash style; `null` drops
* the inherited dash (the writer renders solid); a
* {@link ChartBorderDash} value replaces it. Unrecognized tokens
* (and the OOXML default `"solid"`) collapse to `undefined`.
*/
chartSpaceBorderDash?: ChartBorderDash | null
/** Override `SheetChart.barGrouping`. */
barGrouping?: SheetChart["barGrouping"]
/**
* Override `SheetChart.gapWidth` (only meaningful for `bar` /
* `column`). Dropped silently when the resolved chart type is
* neither — a gap-width hint inherited from a column template never
* leaks into a line / pie clone.
*/
gapWidth?: number
/**
* Override `SheetChart.overlap` (only meaningful for `bar` /
* `column`). Dropped silently when the resolved chart type is
* neither.
*/
overlap?: number
/** Override `SheetChart.lineGrouping`. */
lineGrouping?: SheetChart["lineGrouping"]
/** Override `SheetChart.areaGrouping`. */
areaGrouping?: SheetChart["areaGrouping"]
/**
* Override `SheetChart.dropLines`. `undefined` (or omitted) inherits
* the source's parsed flag; `null` drops the inherited value (the
* writer falls back to the OOXML default of no `<c:dropLines>`); a
* `boolean` replaces it. Only meaningful when the resolved chart type
* is `line` or `area`; silently dropped on every other family.
*/
dropLines?: boolean | null
/**
* Override `SheetChart.hiLowLines`. `undefined` (or omitted) inherits
* the source's parsed flag; `null` drops the inherited value (the
* writer falls back to the OOXML default of no `<c:hiLowLines>`); a
* `boolean` replaces it. Only meaningful when the resolved chart type
* is `line`; silently dropped on every other family (`<c:hiLowLines>`
* has no slot on `<c:areaChart>` per OOXML).
*/
hiLowLines?: boolean | null
/**
* Override `SheetChart.serLines`. `undefined` (or omitted) inherits
* the source's parsed flag; `null` drops the inherited value (the
* writer falls back to the OOXML default of no `<c:serLines>`); a
* `boolean` replaces it. Only meaningful when the resolved chart type
* is `bar` or `column`; silently dropped on every other family
* (`<c:serLines>` has no slot on `<c:lineChart>` / `<c:areaChart>` /
* `<c:pieChart>` / `<c:scatterChart>` per OOXML).
*/
serLines?: boolean | null
/**
* Override `SheetChart.holeSize` (only meaningful for `doughnut`).
* When the resolved chart type is not `doughnut`, the field is
* dropped from the output so it does not leak into a cloned pie or
* column chart.
*/
holeSize?: number
/**
* Override `SheetChart.firstSliceAng` (the pie / doughnut starting
* angle in degrees, clockwise from 12 o'clock). Only meaningful for
* `pie` and `doughnut`; dropped silently when the resolved chart
* type is anything else, so a rotation hint inherited from a
* doughnut template never leaks into a column or scatter clone.
*/
firstSliceAng?: number
/** Override `SheetChart.showTitle`. */
showTitle?: boolean
/**
* Override the chart-level title-overlay flag. `undefined` (or
* omitted) inherits the source's parsed value; `null` drops the
* inherited value (the writer falls back to the OOXML `false` default
* — the title reserves its own slot above the plot area, no overlap);
* a `boolean` replaces it.
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved chart renders no title (`title` resolved to `undefined`
* or `showTitle === false`) — there is no `<c:title>` block to host
* the overlay flag in either case.
*/
titleOverlay?: boolean | null
/**
* Override the chart-level title rotation in whole degrees.
* `undefined` (or omitted) inherits the source's parsed value;
* `null` drops the inherited rotation so the writer falls back to
* the OOXML default `0` (horizontal); a `number` replaces it.
*
* Out-of-range overrides clamp to the `-90..90` band Excel's UI
* exposes; non-integer overrides round to the nearest whole degree;
* `0`, `NaN`, `Infinity`, and non-numeric overrides collapse to a
* drop (the writer's normalization band) so the cloned `SheetChart`
* always carries a value the writer will accept.
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved chart renders no title (`title` resolved to `undefined`
* or `showTitle === false`) — there is no `<c:title>` block to host
* the rotation in either case.
*/
titleRotation?: number | null
/**
* Override the chart-level title font size in whole or half points.
* `undefined` (or omitted) inherits the source's parsed value;
* `null` drops the inherited size so the writer falls back to
* Excel's default 14pt; a `number` replaces it.
*
* Out-of-range overrides (outside the `1..400`pt band the OOXML
* `ST_TextFontSize` schema exposes) collapse to a drop (the writer's
* normalization band) so the cloned `SheetChart` always carries a
* value the writer will accept. Fractional overrides round to the
* nearest 0.5pt (Excel's UI granularity); `NaN`, `Infinity`, and
* non-numeric overrides also collapse to a drop.
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved chart renders no title (`title` resolved to `undefined`
* or `showTitle === false`) — there is no `<c:title>` block to host
* the size in either case. The grammar mirrors `titleRotation` /
* `titleOverlay` so the chart-level title knobs compose the same
* way at the call site.
*/
titleFontSize?: number | null
/**
* Override the chart-level title bold flag.
* `undefined` (or omitted) inherits the source's parsed value;
* `null` drops the inherited flag so the writer falls back to the
* OOXML default `b="0"` (non-bold); a `boolean` replaces it.
*
* Non-boolean overrides (typed escapes from an untyped caller)
* collapse to a drop so the cloned `SheetChart` always carries a
* value the writer will accept.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved chart renders no title (`title` resolved to
* `undefined` or `showTitle === false`) — there is no `<c:title>`
* block to host the flag in either case. The grammar mirrors
* `titleFontSize` / `titleRotation` / `titleOverlay` so the
* chart-level title knobs compose the same way at the call site.
*/
titleBold?: boolean | null
/**
* Override the chart-level title italic flag.
* `undefined` (or omitted) inherits the source's parsed value;
* `null` drops the inherited flag so the writer falls back to the
* OOXML default (no `i` attribute, equivalent to non-italic);
* a `boolean` replaces it.
*
* Non-boolean overrides (typed escapes from an untyped caller)
* collapse to a drop so the cloned `SheetChart` always carries a
* value the writer will accept.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved chart renders no title (`title` resolved to
* `undefined` or `showTitle === false`) — there is no `<c:title>`
* block to host the flag in either case. The grammar mirrors
* `titleBold` / `titleFontSize` / `titleRotation` / `titleOverlay`
* so the chart-level title knobs compose the same way at the call
* site.
*/
titleItalic?: boolean | null
/**
* Override the chart-level title font color.
* `undefined` (or omitted) inherits the source's parsed value;
* `null` drops the inherited fill so the writer falls back to the
* theme text color (no `<a:solidFill>` element on the title's
* default-paragraph properties);
* a 6-character hex string (with or without a leading `#`)
* replaces it.
*
* Malformed overrides (wrong length, non-hex characters,
* alpha-channel forms, non-string escapes) collapse to a drop so
* the cloned `SheetChart` always carries a value the writer will
* accept.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved chart renders no title (`title` resolved to
* `undefined` or `showTitle === false`) — there is no `<c:title>`
* block to host the fill in either case. The grammar mirrors
* `titleBold` / `titleItalic` / `titleFontSize` / `titleRotation`
* / `titleOverlay` so the chart-level title knobs compose the same
* way at the call site.
*/
titleColor?: string | null
/**
* Override the chart-level title strikethrough flag.
* `undefined` (or omitted) inherits the source's parsed `titleStrike`.
* `null` drops the inherited flag (the writer falls back to the
* OOXML default — no `strike` attribute, equivalent to no
* strikethrough).
* A `boolean` replaces it: `true` emits `strike="sngStrike"`
* (Excel's UI "Strikethrough" — single line); `false` pins the
* non-default omission (functionally identical to dropping).
*
* Non-boolean overrides (typed escapes from an untyped caller)
* collapse to a drop so the cloned `SheetChart` always carries a
* value the writer will accept.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved chart renders no title (`title` resolved to
* `undefined` or `showTitle === false`) — there is no `<c:title>`
* block to host the flag in either case. The grammar mirrors
* `titleBold` / `titleItalic` / `titleColor` / `titleFontSize` /
* `titleRotation` / `titleOverlay` so the chart-level title knobs
* compose the same way at the call site.
*/
titleStrike?: boolean | null
/**
* Override the chart-level title underline flag.
* `undefined` (or omitted) inherits the source's parsed `titleUnderline`.
* `null` drops the inherited flag (the writer falls back to the
* OOXML default — no `u` attribute, equivalent to no underline).
* A `boolean` replaces it: `true` emits `u="sng"` (Excel's UI
* "Underline" — single line); `false` pins the non-default omission
* (functionally identical to dropping).
*
* Non-boolean overrides (typed escapes from an untyped caller)
* collapse to a drop so the cloned `SheetChart` always carries a
* value the writer will accept.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved chart renders no title (`title` resolved to
* `undefined` or `showTitle === false`) — there is no `<c:title>`
* block to host the flag in either case. The grammar mirrors
* `titleBold` / `titleItalic` / `titleStrike` / `titleColor` /
* `titleFontSize` / `titleRotation` / `titleOverlay` so the
* chart-level title knobs compose the same way at the call site.
*/
titleUnderline?: boolean | null
/**
* Override the chart-level title font family / typeface.
* `undefined` (or omitted) inherits the source's parsed
* `titleFontFamily`; `null` drops the inherited typeface so the
* writer falls back to the OOXML default (no `<a:latin>` element,
* the title inherits the theme typeface); a non-empty string
* replaces it.
*
* The override is trimmed; empty / whitespace-only strings and
* non-string overrides (typed escapes from an untyped caller)
* collapse to a drop so the cloned `SheetChart` always carries a
* value the writer will accept.
*
* The override is silently dropped from the cloned `SheetChart`
* when the resolved chart renders no title (`title` resolved to
* `undefined` or `showTitle === false`) — there is no `<c:title>`
* block to host the typeface in either case. The grammar mirrors
* `titleColor` (the other string-typed knob) and `titleBold` /
* `titleItalic` / `titleStrike` / `titleUnderline` /
* `titleFontSize` / `titleRotation` / `titleOverlay` so the
* chart-level title knobs compose the same way at the call site.
*/
titleFontFamily?: string | null
/**
* Override the chart-level title manual layout. `undefined` (or
* omitted) inherits the source's parsed `titleLayout`; `null` drops
* the inherited layout so the writer falls back to Excel's auto-
* layout position (the title renders above the plot area, no
* `<c:layout>` block on `<c:title>`); a {@link ChartManualLayout}
* replaces it.
*
* Each of {@link ChartManualLayout.x} / {@link ChartManualLayout.y} /
* {@link ChartManualLayout.w} / {@link ChartManualLayout.h} runs
* through the writer-side `0..1` band — out-of-range / non-finite /
* non-numeric coordinates collapse to `undefined` on the matching
* axis so the cloned `SheetChart` always carries a value the writer
* will accept; an override whose every axis dropped collapses to
* `undefined` so the writer skips the `<c:layout>` block entirely.
*
* The override is silently dropped from the cloned `SheetChart` when
* the resolved chart renders no title (`title` resolved to `undefined`