@automattic/charts 1.10.3 → 1.12.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 (49) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/TOKENS.md +83 -0
  3. package/dist/index.cjs +894 -139
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +58 -62
  6. package/dist/index.d.cts +75 -13
  7. package/dist/index.d.ts +75 -13
  8. package/dist/index.js +894 -139
  9. package/dist/index.js.map +1 -1
  10. package/package.json +2 -1
  11. package/src/charts/area-chart/area-chart.tsx +28 -8
  12. package/src/charts/area-chart/test/area-chart.test.tsx +102 -0
  13. package/src/charts/area-chart/types.ts +20 -6
  14. package/src/charts/bar-chart/bar-chart.tsx +33 -9
  15. package/src/charts/bar-chart/test/bar-chart.test.tsx +117 -0
  16. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +7 -7
  17. package/src/charts/heatmap-chart/heatmap-chart.module.scss +18 -13
  18. package/src/charts/heatmap-chart/heatmap-chart.tsx +11 -7
  19. package/src/charts/heatmap-chart/private/heatmap-legend.tsx +3 -3
  20. package/src/charts/heatmap-chart/test/heatmap-chart.test.tsx +13 -7
  21. package/src/charts/leaderboard-chart/hooks/index.ts +1 -0
  22. package/src/charts/leaderboard-chart/hooks/use-fitted-row-count.ts +115 -0
  23. package/src/charts/leaderboard-chart/leaderboard-chart.module.scss +39 -12
  24. package/src/charts/leaderboard-chart/leaderboard-chart.tsx +67 -14
  25. package/src/charts/leaderboard-chart/test/leaderboard-chart-fit-rows.test.tsx +365 -0
  26. package/src/charts/leaderboard-chart/test/leaderboard-chart.test.tsx +73 -2
  27. package/src/charts/leaderboard-chart/types.ts +12 -0
  28. package/src/charts/line-chart/line-chart.module.scss +2 -2
  29. package/src/charts/line-chart/line-chart.tsx +40 -5
  30. package/src/charts/line-chart/test/line-chart.test.tsx +190 -1
  31. package/src/charts/line-chart/types.ts +14 -0
  32. package/src/charts/private/grid-control/grid-control.module.scss +1 -1
  33. package/src/charts/private/svg-empty-state/svg-empty-state.module.scss +1 -1
  34. package/src/charts/private/x-zoom/index.ts +1 -0
  35. package/src/charts/private/{test → x-zoom/test}/x-zoom.test.tsx +46 -3
  36. package/src/charts/private/x-zoom/x-zoom.module.scss +43 -0
  37. package/src/charts/private/{x-zoom.tsx → x-zoom/x-zoom.tsx} +52 -24
  38. package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +152 -0
  39. package/src/components/legend/hooks/use-chart-legend-items.ts +118 -16
  40. package/src/components/legend/private/base-legend.tsx +21 -9
  41. package/src/components/legend/test/legend-config-types.test.tsx +32 -0
  42. package/src/components/legend/test/legend.test.tsx +121 -1
  43. package/src/components/legend/types.ts +6 -0
  44. package/src/components/tooltip/base-tooltip.module.scss +3 -2
  45. package/src/components/trend-indicator/trend-indicator.module.scss +6 -5
  46. package/src/index.ts +1 -0
  47. package/src/providers/chart-context/themes.ts +33 -19
  48. package/src/types.ts +18 -2
  49. package/src/charts/private/x-zoom.module.scss +0 -48
package/dist/index.css CHANGED
@@ -54,12 +54,12 @@
54
54
  }
55
55
  .a8ccharts--zY0xG-tooltip {
56
56
  padding: var(--wpds-dimension-padding-sm, 8px);
57
+ background-color: var(--a8c-charts-color-tooltip-surface, #000000d9);
57
58
  color: #fff;
58
59
  border-radius: var(--wpds-border-radius-md, 4px);
59
60
  font-size: var(--wpds-typography-font-size-md, 13px);
60
61
  box-shadow: var(--wpds-elevation-sm, 0 1px 2px 0 #0000000d, 0 2px 3px 0 #0000000a, 0 6px 6px 0 #00000008, 0 8px 8px 0 #00000005);
61
62
  pointer-events: none;
62
- background-color: #000000d9;
63
63
  position: absolute;
64
64
  transform: translate(-50%, -100%);
65
65
  }
@@ -79,7 +79,7 @@
79
79
  .a8ccharts-udGPVq-svg-empty-state {
80
80
  text-align: center;
81
81
  font-size: var(--wpds-typography-font-size-md, 13px);
82
- color: var(--wpds-color-foreground-content-neutral-weak, #707070);
82
+ color: var(--a8c-charts-color-label-secondary, var(--wpds-color-foreground-content-neutral-weak, #707070));
83
83
  }
84
84
  .a8ccharts-sP1gHa-container {
85
85
  width: 100%;
@@ -99,45 +99,28 @@
99
99
  min-width: 0;
100
100
  min-height: 0;
101
101
  }
102
- .a8ccharts-y6bXNq-x-zoom__selection {
103
- fill: var(--charts-zoom-selection-fill, #3858e929);
104
- stroke: var(--charts-zoom-selection-stroke, #3858e9a6);
102
+ .a8ccharts-ur9dWW-x-zoom__selection {
103
+ fill: var(--a8c-charts-color-zoom-selection, var(--wpds-color-background-interactive-brand-strong, #3858e9));
104
+ fill-opacity: .16;
105
+ stroke: var(--a8c-charts-color-zoom-selection-stroke, var(--wpds-color-stroke-interactive-brand, #3858e9));
106
+ stroke-opacity: .65;
105
107
  stroke-width: var(--wpds-border-width-xs, 1px);
106
108
  pointer-events: none;
107
109
  }
108
110
 
109
- .a8ccharts-y6bXNq-x-zoom__reset {
111
+ .a8ccharts-ur9dWW-x-zoom__reset {
110
112
  top: var(--wpds-dimension-gap-sm, 8px);
111
113
  right: var(--wpds-dimension-gap-sm, 8px);
112
114
  z-index: 2;
113
- background: var(--charts-zoom-reset-bg, #ffffffeb);
114
- width: 28px;
115
- height: 28px;
116
- color: var(--charts-zoom-reset-fg, var(--wpds-color-foreground-content-neutral, #1e1e1e));
117
- border: var(--wpds-border-width-xs, 1px) solid var(--charts-zoom-reset-border, #00000029);
118
- border-radius: var(--wpds-border-radius-md, 4px);
119
- cursor: pointer;
120
115
  box-shadow: var(--wpds-elevation-xs, 0 1px 1px 0 #00000008, 0 1px 2px 0 #00000005, 0 3px 3px 0 #00000005, 0 4px 4px 0 #00000003);
121
- justify-content: center;
122
- align-items: center;
123
- padding: 0;
124
- display: inline-flex;
116
+ --wp-ui-button-aspect-ratio: 1;
117
+ --wp-ui-button-padding-inline: 0;
118
+ --wp-ui-button-min-width: unset;
125
119
  position: absolute;
126
120
  }
127
121
 
128
- .a8ccharts-y6bXNq-x-zoom__reset:hover {
129
- background: var(--charts-zoom-reset-bg-hover, #fff);
130
- }
131
-
132
- .a8ccharts-y6bXNq-x-zoom__reset:focus-visible {
133
- outline: 2px solid var(--charts-zoom-reset-focus, var(--wpds-color-stroke-focus, #3858e9));
134
- outline-offset: 1px;
135
- }
136
-
137
- .a8ccharts-y6bXNq-x-zoom__reset-icon {
138
- flex-shrink: 0;
139
- width: 16px;
140
- height: 16px;
122
+ .a8ccharts-ur9dWW-x-zoom__reset:not(:hover, :active, :focus) {
123
+ background-color: var(--a8c-charts-color-background, var(--wpds-color-background-surface-neutral-strong, #fff));
141
124
  }
142
125
  .a8ccharts-inuQka-line-chart {
143
126
  position: relative;
@@ -154,8 +137,8 @@
154
137
  }
155
138
 
156
139
  .a8ccharts-inuQka-line-chart__tooltip, .a8ccharts-inuQka-line-chart__annotation-label-popover {
157
- background: var(--wpds-color-background-surface-neutral-strong, #fff);
158
- color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
140
+ background: var(--a8c-charts-color-background, var(--wpds-color-background-surface-neutral-strong, #fff));
141
+ color: var(--a8c-charts-color-label, var(--wpds-color-foreground-content-neutral, #1e1e1e));
159
142
  padding: var(--wpds-dimension-padding-sm, 8px);
160
143
  }
161
144
 
@@ -300,7 +283,7 @@
300
283
  }
301
284
 
302
285
  .a8ccharts-mGEVca-main-rate {
303
- color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
286
+ color: var(--a8c-charts-color-label, var(--wpds-color-foreground-content-neutral, #1e1e1e));
304
287
  text-overflow: ellipsis;
305
288
  font-size: var(--wpds-typography-font-size-xl, 18px);
306
289
  font-style: normal;
@@ -341,7 +324,7 @@
341
324
  }
342
325
 
343
326
  .a8ccharts-mGEVca-step-label {
344
- color: var(--wpds-color-foreground-content-neutral-weak, #707070);
327
+ color: var(--a8c-charts-color-label-secondary, var(--wpds-color-foreground-content-neutral-weak, #707070));
345
328
  font-size: var(--wpds-typography-font-size-sm, 12px);
346
329
  font-weight: var(--wpds-typography-font-weight-regular, 400);
347
330
  line-height: var(--wpds-typography-line-height-xs, 16px);
@@ -351,7 +334,7 @@
351
334
  }
352
335
 
353
336
  .a8ccharts-mGEVca-step-rate {
354
- color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
337
+ color: var(--a8c-charts-color-label, var(--wpds-color-foreground-content-neutral, #1e1e1e));
355
338
  font-size: var(--wpds-typography-font-size-md, 13px);
356
339
  font-weight: var(--wpds-typography-font-weight-medium, 499);
357
340
  line-height: var(--wpds-typography-line-height-xs, 16px);
@@ -384,14 +367,14 @@
384
367
  }
385
368
 
386
369
  .a8ccharts-mGEVca-tooltip-wrapper {
387
- background: var(--wpds-color-background-surface-neutral-strong, #fff);
370
+ background: var(--a8c-charts-color-background, var(--wpds-color-background-surface-neutral-strong, #fff));
388
371
  border-radius: var(--wpds-border-radius-md, 4px) !important;
389
372
  padding: var(--wpds-dimension-padding-md, 12px) !important;
390
373
  box-shadow: var(--wpds-elevation-sm, 0 1px 2px 0 #0000000d, 0 2px 3px 0 #0000000a, 0 6px 6px 0 #00000008, 0 8px 8px 0 #00000005) !important;
391
374
  }
392
375
 
393
376
  .a8ccharts-mGEVca-tooltip-title {
394
- color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
377
+ color: var(--a8c-charts-color-label, var(--wpds-color-foreground-content-neutral, #1e1e1e));
395
378
  font-size: var(--wpds-typography-font-size-sm, 12px);
396
379
  font-style: normal;
397
380
  font-weight: var(--wpds-typography-font-weight-regular, 400);
@@ -399,7 +382,7 @@
399
382
  }
400
383
 
401
384
  .a8ccharts-mGEVca-tooltip-content {
402
- color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
385
+ color: var(--a8c-charts-color-label, var(--wpds-color-foreground-content-neutral, #1e1e1e));
403
386
  font-size: var(--wpds-typography-font-size-md, 13px);
404
387
  font-style: normal;
405
388
  font-weight: var(--wpds-typography-font-weight-medium, 499);
@@ -408,7 +391,7 @@
408
391
 
409
392
  .a8ccharts-mGEVca-empty-state {
410
393
  text-align: center;
411
- color: var(--wpds-color-foreground-content-neutral-weak, #707070);
394
+ color: var(--a8c-charts-color-label-secondary, var(--wpds-color-foreground-content-neutral-weak, #707070));
412
395
  font-size: var(--wpds-typography-font-size-lg, 16px);
413
396
  }
414
397
  .a8ccharts-8hS2IW-container {
@@ -427,11 +410,11 @@
427
410
 
428
411
  .a8ccharts-O3YMOW-heatmap-chart__empty {
429
412
  padding: var(--wpds-dimension-padding-lg, 16px);
430
- color: var(--wpds-color-foreground-content-neutral-weak, #707070);
413
+ color: var(--a8c-charts-color-label-secondary, var(--wpds-color-foreground-content-neutral-weak, #707070));
431
414
  }
432
415
 
433
416
  .a8ccharts-O3YMOW-heatmap-chart__grid {
434
- gap: var(--heatmap-cell-gap, var(--wpds-dimension-gap-xs, 4px));
417
+ gap: var(--a8c-charts-dimension-heatmap-cell-gap, var(--wpds-dimension-gap-xs, 4px));
435
418
  flex: 1 1 0;
436
419
  width: 100%;
437
420
  min-height: 0;
@@ -439,7 +422,7 @@
439
422
  }
440
423
 
441
424
  .a8ccharts-O3YMOW-heatmap-chart__grid:focus-visible {
442
- outline: var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px)) solid var(--wpds-color-stroke-focus, var(--wp-admin-theme-color, #3858e9));
425
+ outline: var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px)) solid var(--a8c-charts-color-focus, var(--wpds-color-stroke-focus, var(--wp-admin-theme-color, #3858e9)));
443
426
  outline-offset: 2px;
444
427
  border-radius: var(--wpds-border-radius-sm, 2px);
445
428
  }
@@ -462,7 +445,7 @@
462
445
  }
463
446
 
464
447
  .a8ccharts-O3YMOW-heatmap-chart__col-label, .a8ccharts-O3YMOW-heatmap-chart__row-label {
465
- color: var(--wpds-color-foreground-content-neutral-weak, #707070);
448
+ color: var(--a8c-charts-color-label-secondary, var(--wpds-color-foreground-content-neutral-weak, #707070));
466
449
  font-size: var(--wpds-typography-font-size-xs, 11px);
467
450
  white-space: nowrap;
468
451
  overflow: visible;
@@ -481,7 +464,7 @@
481
464
 
482
465
  .a8ccharts-O3YMOW-heatmap-chart__cell {
483
466
  border-radius: var(--wpds-border-radius-sm, 2px);
484
- background: var(--wpds-color-background-track-neutral-weak, #f0f0f0);
467
+ background: var(--a8c-charts-color-track, var(--wpds-color-background-track-neutral-weak, #f0f0f0));
485
468
  justify-content: center;
486
469
  align-items: center;
487
470
  min-width: 0;
@@ -495,28 +478,28 @@
495
478
  }
496
479
 
497
480
  .a8ccharts-O3YMOW-heatmap-chart__cell--filled {
498
- background: color-mix(in sRGB, var(--heatmap-primary) calc((.15 + .85 * var(--intensity)) * 100%), var(--heatmap-bg, #fff));
481
+ background: color-mix(in sRGB, var(--a8c-charts-color-heatmap-primary) calc((.15 + .85 * var(--a8c-charts-heatmap-cell-intensity)) * 100%), var(--a8c-charts-color-heatmap-background, #fff));
499
482
  }
500
483
 
501
484
  .a8ccharts-O3YMOW-heatmap-chart__cell--selected {
502
- outline: var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px)) solid var(--wpds-color-stroke-focus, var(--wp-admin-theme-color, #3858e9));
485
+ outline: var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px)) solid var(--a8c-charts-color-focus, var(--wpds-color-stroke-focus, var(--wp-admin-theme-color, #3858e9)));
503
486
  outline-offset: calc(-1 * var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px)));
504
487
  }
505
488
 
506
489
  .a8ccharts-O3YMOW-heatmap-chart__cell-value {
507
- color: var(--wpds-color-foreground-content-neutral, #1e1e1e);
490
+ color: var(--a8c-charts-color-label, var(--wpds-color-foreground-content-neutral, #1e1e1e));
508
491
  font-size: var(--wpds-typography-font-size-md, 13px);
509
492
  }
510
493
 
511
494
  .a8ccharts-O3YMOW-heatmap-chart__cell--strong .a8ccharts-O3YMOW-heatmap-chart__cell-value {
512
- color: var(--wpds-color-foreground-interactive-neutral-strong, #f0f0f0);
495
+ color: var(--a8c-charts-color-label-inverse, var(--wpds-color-foreground-interactive-neutral-strong, #f0f0f0));
513
496
  }
514
497
 
515
498
  .a8ccharts-O3YMOW-heatmap-chart__legend-swatch {
516
499
  width: var(--wpds-dimension-size-3xs, 12px);
517
500
  height: var(--wpds-dimension-size-3xs, 12px);
518
501
  border-radius: var(--wpds-border-radius-sm, 2px);
519
- background: color-mix(in sRGB, var(--heatmap-primary) calc((.15 + .85 * var(--intensity)) * 100%), var(--heatmap-bg, #fff));
502
+ background: color-mix(in sRGB, var(--a8c-charts-color-heatmap-primary) calc((.15 + .85 * var(--a8c-charts-heatmap-cell-intensity)) * 100%), var(--a8c-charts-color-heatmap-background, #fff));
520
503
  }
521
504
  .a8ccharts-GovfoW-leaderboardChart {
522
505
  transition: opacity var(--wpds-motion-duration-lg, .3s) var(--wpds-motion-easing-subtle, cubic-bezier(.15, 0, .15, 1));
@@ -537,6 +520,11 @@
537
520
  overflow: auto;
538
521
  }
539
522
 
523
+ .a8ccharts-GovfoW-leaderboardChart__content--fit {
524
+ position: relative;
525
+ overflow: hidden;
526
+ }
527
+
540
528
  .a8ccharts-GovfoW-barWithLabelContainer {
541
529
  isolation: isolate;
542
530
  grid-template-columns: 1fr;
@@ -562,7 +550,7 @@
562
550
  height: 100%;
563
551
  min-height: 6px;
564
552
  min-width: var(--wpds-dimension-size-5xs, 4px);
565
- border-radius: var(--a8c--charts--leaderboard--bar--border-radius, 9999px);
553
+ border-radius: var(--a8c-charts-border-radius-leaderboard-bar, var(--a8c--charts--leaderboard--bar--border-radius, 9999px));
566
554
  z-index: -1;
567
555
  }
568
556
 
@@ -602,16 +590,24 @@
602
590
  .a8ccharts-GovfoW-emptyState {
603
591
  padding: var(--wpds-dimension-padding-3xl, 32px) var(--wpds-dimension-padding-lg, 16px);
604
592
  text-align: center;
605
- color: var(--wpds-color-foreground-content-neutral-weak, #707070);
593
+ color: var(--a8c-charts-color-label-secondary, var(--wpds-color-foreground-content-neutral-weak, #707070));
606
594
  font-size: var(--wpds-typography-font-size-md, 13px);
607
595
  font-style: italic;
608
596
  }
609
597
 
598
+ .a8ccharts-GovfoW-fitEmptyState {
599
+ justify-content: center;
600
+ align-items: center;
601
+ padding-block: 0;
602
+ display: flex;
603
+ position: absolute;
604
+ inset: 0;
605
+ }
606
+
610
607
  .a8ccharts-GovfoW-row {
611
- --focus-ring-width: var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px));
612
608
  grid-column: 1 / -1;
613
609
  grid-template-columns: subgrid;
614
- padding: var(--focus-ring-width);
610
+ padding: var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px));
615
611
  align-items: center;
616
612
  display: grid;
617
613
  }
@@ -636,7 +632,7 @@
636
632
  }
637
633
 
638
634
  .a8ccharts-GovfoW-interactiveRow:hover, .a8ccharts-GovfoW-interactiveRow:focus-visible {
639
- --a8c--charts--leaderboard--bar--hover-inset: var(--wpds-dimension-gap-2xl, 32px);
635
+ --a8c-charts-dimension-leaderboard-bar-hover-inset: var(--wpds-dimension-gap-2xl, 32px);
640
636
  }
641
637
 
642
638
  .a8ccharts-GovfoW-interactiveRow:hover .a8ccharts-GovfoW-bar, .a8ccharts-GovfoW-interactiveRow:focus-visible .a8ccharts-GovfoW-bar {
@@ -644,7 +640,7 @@
644
640
  }
645
641
 
646
642
  .a8ccharts-GovfoW-interactiveRow:hover .a8ccharts-GovfoW-valueContainer, .a8ccharts-GovfoW-interactiveRow:focus-visible .a8ccharts-GovfoW-valueContainer {
647
- transform: translateX(calc(var(--a8c--charts--leaderboard--bar--hover-inset) * -1));
643
+ transform: translateX(calc(var(--a8c-charts-dimension-leaderboard-bar-hover-inset) * -1));
648
644
  }
649
645
 
650
646
  .a8ccharts-GovfoW-interactiveRow:hover .a8ccharts-GovfoW-chevron, .a8ccharts-GovfoW-interactiveRow:focus-visible .a8ccharts-GovfoW-chevron {
@@ -652,19 +648,19 @@
652
648
  }
653
649
 
654
650
  [dir="rtl"] .a8ccharts-GovfoW-interactiveRow:hover .a8ccharts-GovfoW-valueContainer, [dir="rtl"] .a8ccharts-GovfoW-interactiveRow:focus-visible .a8ccharts-GovfoW-valueContainer {
655
- transform: translateX(var(--a8c--charts--leaderboard--bar--hover-inset));
651
+ transform: translateX(var(--a8c-charts-dimension-leaderboard-bar-hover-inset));
656
652
  }
657
653
 
658
654
  .a8ccharts-GovfoW-interactiveRow:focus-visible {
659
655
  border-radius: var(--wpds-border-radius-sm, 2px);
660
- outline: var(--focus-ring-width) solid var(--wpds-color-stroke-focus, var(--wp-admin-theme-color, #3858e9));
661
- outline-offset: calc(-1 * var(--focus-ring-width));
656
+ outline: var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px)) solid var(--a8c-charts-color-focus, var(--wpds-color-stroke-focus, var(--wp-admin-theme-color, #3858e9)));
657
+ outline-offset: calc(-1 * var(--wpds-border-width-focus, var(--wp-admin-border-width-focus, 2px)));
662
658
  }
663
659
 
664
660
  .a8ccharts-GovfoW-chevron {
665
661
  inset-inline-end: var(--wpds-dimension-padding-xs, 4px);
666
662
  opacity: 0;
667
- color: var(--wpds-color-foreground-content-neutral-weak, #707070);
663
+ color: var(--a8c-charts-color-label-secondary, var(--wpds-color-foreground-content-neutral-weak, #707070));
668
664
  transition: opacity var(--wpds-motion-duration-sm, .1s) var(--wpds-motion-easing-subtle, cubic-bezier(.15, 0, .15, 1));
669
665
  pointer-events: none;
670
666
  margin-block: auto;
@@ -731,15 +727,15 @@
731
727
  }
732
728
 
733
729
  .a8ccharts-zR7F7G-trend-indicator--up {
734
- color: var(--charts-trend-up-color, var(--wpds-color-foreground-content-success-weak, #008030));
730
+ color: var(--a8c-charts-color-trend-up, var(--charts-trend-up-color, var(--wpds-color-foreground-content-success-weak, #008030)));
735
731
  }
736
732
 
737
733
  .a8ccharts-zR7F7G-trend-indicator--down {
738
- color: var(--charts-trend-down-color, var(--wpds-color-foreground-content-error-weak, #cc1818));
734
+ color: var(--a8c-charts-color-trend-down, var(--charts-trend-down-color, var(--wpds-color-foreground-content-error-weak, #cc1818)));
739
735
  }
740
736
 
741
737
  .a8ccharts-zR7F7G-trend-indicator--neutral {
742
- color: var(--charts-trend-neutral-color, var(--wpds-color-foreground-content-neutral-weak, #707070));
738
+ color: var(--a8c-charts-color-trend-neutral, var(--charts-trend-neutral-color, var(--wpds-color-foreground-content-neutral-weak, #707070)));
743
739
  }
744
740
 
745
741
  .a8ccharts-zR7F7G-trend-indicator__icon {
package/dist/index.d.cts CHANGED
@@ -152,8 +152,8 @@ type LeaderboardEntry = {
152
152
  */
153
153
  previousShare?: number;
154
154
  /**
155
- * Delta of the entry. Omit when this row has no matching comparison-period
156
- * value.
155
+ * Delta of the entry. Omit when the percentage change is unavailable, such
156
+ * as when the row has no comparison value or its previous value is zero.
157
157
  */
158
158
  delta?: number;
159
159
  /**
@@ -481,6 +481,21 @@ type ChartLegendConfig<T = DataPoint | DataPointDate | LeaderboardEntry> = {
481
481
  */
482
482
  shapeStyles?: LegendShapeStyles;
483
483
  };
484
+ /**
485
+ * Legend config for charts built from `SeriesData` (line, bar, area). Adds `collapseGroups` on top
486
+ * of the shared config. It is intentionally absent from the base `ChartLegendConfig` so point-based
487
+ * charts (pie, semi-circle pie) — whose data points carry `group` only to coordinate colours — can't
488
+ * set it.
489
+ */
490
+ type SeriesChartLegendConfig = ChartLegendConfig<SeriesData[]> & {
491
+ /**
492
+ * Collapse series that share a `group` into a single legend item, labelled by the group's
493
+ * primary series (its first non-comparison member). Off by default, so every series keeps its
494
+ * own item. Combines with `interactive`: a collapsed item toggles every series in its group, an
495
+ * uncollapsed one toggles only its own.
496
+ */
497
+ collapseGroups?: boolean;
498
+ };
484
499
  /**
485
500
  * Base properties shared across all chart components
486
501
  */
@@ -644,6 +659,12 @@ type BaseLegendItem = {
644
659
  glyphSize?: number;
645
660
  renderGlyph?: <Datum extends object>(props: GlyphProps<Datum>) => ReactNode;
646
661
  shapeStyle?: CSSProperties & LineStyles$1;
662
+ /**
663
+ * The series labels this legend item controls. For a grouped item this is every series
664
+ * sharing the group (primary first); for a single series it is just its own label. Used by
665
+ * the interactive legend to toggle a whole group's visibility from one item.
666
+ */
667
+ seriesLabels?: string[];
647
668
  };
648
669
  //#endregion
649
670
  //#region src/components/legend/legend.d.ts
@@ -661,6 +682,11 @@ interface ChartLegendOptions {
661
682
  showValues?: boolean;
662
683
  legendValueDisplay?: LegendValueDisplay;
663
684
  legendShape?: LegendShape<SeriesData[], number>;
685
+ /**
686
+ * Collapse series that share a `group` into a single legend item, labelled by the group's
687
+ * primary series. Off by default, so every series gets its own item.
688
+ */
689
+ collapseGroups?: boolean;
664
690
  }
665
691
  /**
666
692
  * Hook to transform chart data into legend items
@@ -736,6 +762,10 @@ type RenderLineGlyphProps<Datum extends object> = GlyphProps<Datum> & {
736
762
  position?: 'start' | 'end';
737
763
  };
738
764
  interface LineChartProps extends BaseChartProps<SeriesData[]> {
765
+ /**
766
+ * Legend configuration. Supports `collapseGroups` on top of the shared options.
767
+ */
768
+ legend?: SeriesChartLegendConfig;
739
769
  withGradientFill: boolean;
740
770
  smoothing?: boolean;
741
771
  curveType?: CurveType;
@@ -755,6 +785,15 @@ interface LineChartProps extends BaseChartProps<SeriesData[]> {
755
785
  * button appears in the top-right of the chart while zoomed.
756
786
  */
757
787
  zoomable?: boolean;
788
+ /**
789
+ * Whether the Y axis rescales to fit only the visible series when series are
790
+ * hidden or shown through the interactive legend.
791
+ * Defaults to `true` (the pre-existing behaviour). Set to `false` to pin the Y
792
+ * axis to the full data extent so hiding series does not move the chart's
793
+ * baseline — useful for comparison charts. Matches `AreaChart`.
794
+ * @default true
795
+ */
796
+ rescaleYOnVisibilityChange?: boolean;
758
797
  children?: ReactNode;
759
798
  }
760
799
  type TooltipDatum = {
@@ -764,6 +803,10 @@ type TooltipDatum = {
764
803
  //#endregion
765
804
  //#region src/charts/area-chart/types.d.ts
766
805
  interface AreaChartProps extends BaseChartProps<SeriesData[]> {
806
+ /**
807
+ * Legend configuration. Supports `collapseGroups` on top of the shared options.
808
+ */
809
+ legend?: SeriesChartLegendConfig;
767
810
  /**
768
811
  * Whether series should be stacked on top of each other.
769
812
  * When false, series are rendered as overlapping filled areas.
@@ -814,13 +857,18 @@ interface AreaChartProps extends BaseChartProps<SeriesData[]> {
814
857
  */
815
858
  zoomable?: boolean;
816
859
  /**
817
- * When using an interactive legend, controls whether the Y axis rescales
818
- * to fit only the visible series. Defaults to `true`, matching the
819
- * intuitive default for LineChart and BarChart. Set to `false` to pin
820
- * the Y axis to the full data extent so toggling legend items off does
821
- * not move the chart's baseline.
860
+ * Whether the Y axis rescales to fit only the visible series when series are
861
+ * hidden or shown through the interactive legend.
862
+ * Defaults to `true`, matching LineChart. Set to `false` to pin the Y axis to
863
+ * the full data extent so hiding series does not move the chart's baseline.
822
864
  * @default true
823
865
  */
866
+ rescaleYOnVisibilityChange?: boolean;
867
+ /**
868
+ * @deprecated Use `rescaleYOnVisibilityChange`. The behaviour keys off series
869
+ * visibility changing, not specifically a legend toggle. Still honoured when
870
+ * `rescaleYOnVisibilityChange` is not set.
871
+ */
824
872
  rescaleYOnLegendToggle?: boolean;
825
873
  children?: ReactNode;
826
874
  }
@@ -859,6 +907,10 @@ declare const AreaChartResponsive: AreaChartResponsiveComponent;
859
907
  //#endregion
860
908
  //#region src/charts/bar-chart/bar-chart.d.ts
861
909
  interface BarChartProps extends BaseChartProps<SeriesData[]> {
910
+ /**
911
+ * Legend configuration. Supports `collapseGroups` on top of the shared options.
912
+ */
913
+ legend?: SeriesChartLegendConfig;
862
914
  renderTooltip?: (params: RenderTooltipParams<DataPointDate>) => ReactNode;
863
915
  orientation?: 'horizontal' | 'vertical';
864
916
  withPatterns?: boolean;
@@ -946,7 +998,7 @@ declare const BarListChartResponsive: ({
946
998
  width,
947
999
  height,
948
1000
  ...chartProps
949
- }: Omit<BarListChartProps, "width" | "height" | "size"> & {
1001
+ }: Omit<BarListChartProps, "height" | "size" | "width"> & {
950
1002
  width?: number;
951
1003
  height?: number;
952
1004
  size?: number;
@@ -1100,7 +1152,7 @@ declare const GeoChartResponsive: ({
1100
1152
  width,
1101
1153
  height,
1102
1154
  ...chartProps
1103
- }: Omit<GeoChartProps, "width" | "height" | "size"> & {
1155
+ }: Omit<GeoChartProps, "height" | "size" | "width"> & {
1104
1156
  width?: number;
1105
1157
  height?: number;
1106
1158
  size?: number;
@@ -1231,10 +1283,20 @@ interface LeaderboardChartProps extends Pick<BaseChartProps<LeaderboardEntry>, '
1231
1283
  * Whether the chart is in loading state
1232
1284
  */
1233
1285
  loading?: boolean;
1286
+ /**
1287
+ * Show only complete rows that fit the chart height instead of scrolling.
1288
+ *
1289
+ * Requires a container that constrains the chart's height; otherwise every
1290
+ * row fits. Refits are debounced with the parent resize on the responsive
1291
+ * export, so `LeaderboardChartUnresponsive` tracks a live drag more closely.
1292
+ * @default false
1293
+ */
1294
+ fitRows?: boolean;
1234
1295
  /**
1235
1296
  * Custom styling for the chart container
1236
1297
  */
1237
1298
  style?: React.CSSProperties & {
1299
+ '--a8c-charts-border-radius-leaderboard-bar'?: string; /** @deprecated Use `--a8c-charts-border-radius-leaderboard-bar`. */
1238
1300
  '--a8c--charts--leaderboard--bar--border-radius'?: string;
1239
1301
  };
1240
1302
  /**
@@ -1271,7 +1333,7 @@ declare const LeaderboardChartResponsive: (({
1271
1333
  width,
1272
1334
  height,
1273
1335
  ...chartProps
1274
- }: Omit<LeaderboardChartProps, "width" | "height" | "size"> & {
1336
+ }: Omit<LeaderboardChartProps, "height" | "size" | "width"> & {
1275
1337
  width?: number;
1276
1338
  height?: number;
1277
1339
  size?: number;
@@ -1804,7 +1866,7 @@ declare const Sparkline: ({
1804
1866
  width,
1805
1867
  height,
1806
1868
  ...chartProps
1807
- }: Omit<SparklineProps, "width" | "height" | "size"> & {
1869
+ }: Omit<SparklineProps, "height" | "size" | "width"> & {
1808
1870
  width?: number;
1809
1871
  height?: number;
1810
1872
  size?: number;
@@ -1852,7 +1914,7 @@ declare const BaseTooltip: ({
1852
1914
  className,
1853
1915
  style,
1854
1916
  renderContainer
1855
- }: BaseTooltipProps) => string | number | true | Iterable<ReactNode> | import("react/jsx-runtime").JSX.Element;
1917
+ }: BaseTooltipProps) => string | number | true | import("react/jsx-runtime").JSX.Element | Iterable<ReactNode>;
1856
1918
  //#endregion
1857
1919
  //#region src/components/tooltip/accessible-tooltip.d.ts
1858
1920
  type FlattenedTooltipData = {
@@ -1998,5 +2060,5 @@ declare const useGlobalChartsTheme: () => CompleteChartTheme;
1998
2060
  */
1999
2061
  declare const defaultTheme: CompleteChartTheme;
2000
2062
  //#endregion
2001
- export { AccessibleTooltip, type AnnotationStyles, type ArcData, AreaChartResponsive as AreaChart, type AreaChartProps, AreaChart as AreaChartUnresponsive, type AxisOptions, BarChartResponsive as BarChart, type BarChartProps, BarChart as BarChartUnresponsive, BarListChartResponsive as BarListChart, type BarListChartProps, BarListChart as BarListChartUnresponsive, type BaseChartProps, type BaseLegendItem, type BaseLegendProps, BaseTooltip, type BaseTooltipProps, type CalendarHeatmapResult, type ChartLegendConfig, type ChartLegendOptions, type ChartTheme, type CompleteChartTheme, ConversionFunnelChartWithProvider as ConversionFunnelChart, type ConversionFunnelChartProps, type CurveType, type DataPoint, type DataPointDate, type DataPointPercentage, type EventHandlerParams, type FunnelStep, GeoChartResponsive as GeoChart, type GeoChartError, type GeoChartProps, GeoChartWithProvider as GeoChartUnresponsive, type GeoData, type GeoRegion, type GeoResolution, GlobalChartsContext, GlobalChartsProvider, GlobalChartsProvider as ThemeProvider, type GoogleDataTableColumn, type GoogleDataTableColumnRoleType, type GoogleDataTableRow, type GradientConfig, type GradientStop, type GridProps, type GridStyles, type HeatmapCell, HeatmapChartResponsive as HeatmapChart, type HeatmapChartProps, HeatmapChart as HeatmapChartUnresponsive, type HeatmapColumn, type HeatmapTooltipData, LeaderboardChartResponsive as LeaderboardChart, type LeaderboardChartProps, LeaderboardChart as LeaderboardChartUnresponsive, type LeaderboardEntry, Legend, type LegendItemStyles, type LegendLabelStyles, type LegendPosition, type LegendProps, type LegendShape, type LegendShapeLabel, type LegendShapeRenderProps, type LegendShapeStyles, type LegendValueDisplay, LineChartResponsive as LineChart, type LineChartAnnotationProps, type LineChartProps, LineChart as LineChartUnresponsive, type LineStyles, type MainMetricRenderProps, type MetricValueType, type MultipleDataPointsDate, type Optional, type OrientationType, PieChartResponsive as PieChart, type PieChartProps, type PieChartRenderTooltipParams, PieChart as PieChartUnresponsive, PieSemiCircleChartResponsive as PieSemiCircleChart, type PieSemiCircleChartProps, type PieSemiCircleChartRenderTooltipParams, PieSemiCircleChart as PieSemiCircleChartUnresponsive, type RenderLabelProps, type RenderLineGlyphProps, type RenderTooltipGlyphProps, type RenderTooltipParams, type RenderValueProps, type ScaleOptions, type SeriesData, type SeriesDataOptions, Sparkline, type SparklineDataPoint, type SparklineProps, SparklineUnresponsive, type StepLabelRenderProps, type StepRateRenderProps, type TooltipData, type TooltipDatum, type TooltipProps, type TooltipRenderProps, type TrendDirection, TrendIndicator, type TrendIndicatorProps, type XyChartTooltipProps, buildCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, parseRgbString, prefersLightText, relativeLuminance, useChartLegendItems, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, validateHexColor };
2063
+ export { AccessibleTooltip, type AnnotationStyles, type ArcData, AreaChartResponsive as AreaChart, type AreaChartProps, AreaChart as AreaChartUnresponsive, type AxisOptions, BarChartResponsive as BarChart, type BarChartProps, BarChart as BarChartUnresponsive, BarListChartResponsive as BarListChart, type BarListChartProps, BarListChart as BarListChartUnresponsive, type BaseChartProps, type BaseLegendItem, type BaseLegendProps, BaseTooltip, type BaseTooltipProps, type CalendarHeatmapResult, type ChartLegendConfig, type ChartLegendOptions, type ChartTheme, type CompleteChartTheme, ConversionFunnelChartWithProvider as ConversionFunnelChart, type ConversionFunnelChartProps, type CurveType, type DataPoint, type DataPointDate, type DataPointPercentage, type EventHandlerParams, type FunnelStep, GeoChartResponsive as GeoChart, type GeoChartError, type GeoChartProps, GeoChartWithProvider as GeoChartUnresponsive, type GeoData, type GeoRegion, type GeoResolution, GlobalChartsContext, GlobalChartsProvider, GlobalChartsProvider as ThemeProvider, type GoogleDataTableColumn, type GoogleDataTableColumnRoleType, type GoogleDataTableRow, type GradientConfig, type GradientStop, type GridProps, type GridStyles, type HeatmapCell, HeatmapChartResponsive as HeatmapChart, type HeatmapChartProps, HeatmapChart as HeatmapChartUnresponsive, type HeatmapColumn, type HeatmapTooltipData, LeaderboardChartResponsive as LeaderboardChart, type LeaderboardChartProps, LeaderboardChart as LeaderboardChartUnresponsive, type LeaderboardEntry, Legend, type LegendItemStyles, type LegendLabelStyles, type LegendPosition, type LegendProps, type LegendShape, type LegendShapeLabel, type LegendShapeRenderProps, type LegendShapeStyles, type LegendValueDisplay, LineChartResponsive as LineChart, type LineChartAnnotationProps, type LineChartProps, LineChart as LineChartUnresponsive, type LineStyles, type MainMetricRenderProps, type MetricValueType, type MultipleDataPointsDate, type Optional, type OrientationType, PieChartResponsive as PieChart, type PieChartProps, type PieChartRenderTooltipParams, PieChart as PieChartUnresponsive, PieSemiCircleChartResponsive as PieSemiCircleChart, type PieSemiCircleChartProps, type PieSemiCircleChartRenderTooltipParams, PieSemiCircleChart as PieSemiCircleChartUnresponsive, type RenderLabelProps, type RenderLineGlyphProps, type RenderTooltipGlyphProps, type RenderTooltipParams, type RenderValueProps, type ScaleOptions, type SeriesChartLegendConfig, type SeriesData, type SeriesDataOptions, Sparkline, type SparklineDataPoint, type SparklineProps, SparklineUnresponsive, type StepLabelRenderProps, type StepRateRenderProps, type TooltipData, type TooltipDatum, type TooltipProps, type TooltipRenderProps, type TrendDirection, TrendIndicator, type TrendIndicatorProps, type XyChartTooltipProps, buildCalendarHeatmapData, defaultTheme, formatMetricValue, formatPercentage, getColorDistance, hexToRgba, isValidHexColor, lightenHexColor, mergeThemes, mixHexColors, normalizeColorToHex, parseAsLocalDate, parseHslString, parseRgbString, prefersLightText, relativeLuminance, useChartLegendItems, useGlobalChartsContext, useGlobalChartsTheme, useLeaderboardLegendItems, validateHexColor };
2002
2064
  //# sourceMappingURL=index.d.cts.map