@classic-homes/charts-core 0.1.37 → 0.3.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.
@@ -1,3 +1,6 @@
1
+ import { EChartsOption } from 'echarts';
2
+ import { EChartsType } from 'echarts/core';
3
+
1
4
  /**
2
5
  * Data structure types for all chart components
3
6
  */
@@ -10,10 +13,17 @@ interface LineChartData {
10
13
  interface LineSeriesData {
11
14
  /** Series name (shown in legend) */
12
15
  name: string;
13
- /** Data values corresponding to categories */
14
- data: number[];
16
+ /** Data values corresponding to categories; `null` marks a missing value (a gap) */
17
+ data: (number | null)[];
15
18
  /** Override theme color for this series */
16
19
  color?: string;
20
+ /** Per-point label text, by data index (shown on those points; templates allowed) */
21
+ labels?: (string | null | undefined)[];
22
+ /**
23
+ * Stack group: series with the same id stack on each other. Overrides the
24
+ * chart's `stacked` prop for this series.
25
+ */
26
+ stack?: string;
17
27
  }
18
28
  interface BarChartData {
19
29
  /** Category labels */
@@ -24,10 +34,17 @@ interface BarChartData {
24
34
  interface BarSeriesData {
25
35
  /** Series name (shown in legend) */
26
36
  name: string;
27
- /** Data values corresponding to categories */
28
- data: number[];
37
+ /** Data values corresponding to categories; `null` marks a missing value (a gap) */
38
+ data: (number | null)[];
29
39
  /** Override theme color for this series */
30
40
  color?: string;
41
+ /** Per-point label text, by data index (shown on those points; templates allowed) */
42
+ labels?: (string | null | undefined)[];
43
+ /**
44
+ * Stack group: series with the same id stack on each other. Overrides the
45
+ * chart's `stacked` prop for this series.
46
+ */
47
+ stack?: string;
31
48
  }
32
49
  interface PieSliceData {
33
50
  /** Slice name (shown in legend/tooltip) */
@@ -36,6 +53,8 @@ interface PieSliceData {
36
53
  value: number;
37
54
  /** Override theme color for this slice */
38
55
  color?: string;
56
+ /** Label text shown for this slice instead of the default (templates allowed) */
57
+ label?: string;
39
58
  }
40
59
  interface AreaChartData {
41
60
  /** X-axis category labels */
@@ -46,10 +65,17 @@ interface AreaChartData {
46
65
  interface AreaSeriesData {
47
66
  /** Series name (shown in legend) */
48
67
  name: string;
49
- /** Data values corresponding to categories */
50
- data: number[];
68
+ /** Data values corresponding to categories; `null` marks a missing value (a gap) */
69
+ data: (number | null)[];
51
70
  /** Override theme color for this series */
52
71
  color?: string;
72
+ /** Per-point label text, by data index (shown on those points; templates allowed) */
73
+ labels?: (string | null | undefined)[];
74
+ /**
75
+ * Stack group: series with the same id stack on each other. Overrides the
76
+ * chart's `stacked` prop for this series.
77
+ */
78
+ stack?: string;
53
79
  }
54
80
  interface ScatterChartData {
55
81
  /** Data series */
@@ -62,6 +88,8 @@ interface ScatterSeriesData {
62
88
  data: [number, number][];
63
89
  /** Override theme color for this series */
64
90
  color?: string;
91
+ /** Per-point label text, by data index (shown on those points; templates allowed) */
92
+ labels?: (string | null | undefined)[];
65
93
  }
66
94
  interface RadarChartData {
67
95
  /** Data series */
@@ -90,6 +118,8 @@ interface FunnelSliceData {
90
118
  value: number;
91
119
  /** Override theme color for this slice */
92
120
  color?: string;
121
+ /** Label text shown for this stage instead of the default (templates allowed) */
122
+ label?: string;
93
123
  }
94
124
  interface HeatmapData {
95
125
  /** Data points as [xIndex, yIndex, value] */
@@ -108,6 +138,8 @@ interface TreemapNode {
108
138
  children?: TreemapNode[];
109
139
  /** Override theme color for this node */
110
140
  color?: string;
141
+ /** Label text shown for this node instead of the default (templates allowed) */
142
+ label?: string;
111
143
  }
112
144
  interface TreemapLevel {
113
145
  /** Level index (0 = root) */
@@ -153,6 +185,8 @@ interface SankeyNode {
153
185
  name: string;
154
186
  /** Override theme color for this node */
155
187
  color?: string;
188
+ /** Label text shown for this node instead of the default (templates allowed) */
189
+ label?: string;
156
190
  }
157
191
  interface SankeyLink {
158
192
  /** Source node name */
@@ -162,6 +196,147 @@ interface SankeyLink {
162
196
  /** Flow value */
163
197
  value: number;
164
198
  }
199
+ /**
200
+ * The categories x series shape shared by line, bar and area charts
201
+ */
202
+ interface CategoryChartData {
203
+ /** Category labels */
204
+ categories: string[];
205
+ /** Data series */
206
+ series: CategorySeriesData[];
207
+ }
208
+ interface CategorySeriesData {
209
+ /** Series name (shown in legend) */
210
+ name: string;
211
+ /** Values by category index; `null` marks a missing value */
212
+ data: (number | null)[];
213
+ /** Override theme color for this series */
214
+ color?: string;
215
+ /** Per-point label text, by data index */
216
+ labels?: (string | null | undefined)[];
217
+ /** Stack group id */
218
+ stack?: string;
219
+ }
220
+ interface ComboChartData {
221
+ /** Category labels */
222
+ categories: string[];
223
+ /** Data series, each drawn as bars, a line or an area */
224
+ series: ComboSeriesData[];
225
+ }
226
+ interface ComboSeriesData extends CategorySeriesData {
227
+ /** How the series is drawn (defaults to 'bar') */
228
+ type?: 'bar' | 'line' | 'area';
229
+ /** Value axis the series is measured on (defaults to 'primary', on the left) */
230
+ axis?: 'primary' | 'secondary';
231
+ }
232
+ interface DotPlotChartData {
233
+ /** Category labels, one row each */
234
+ categories: string[];
235
+ /** Data series; each draws one dot per category */
236
+ series: DotPlotSeriesData[];
237
+ }
238
+ interface DotPlotSeriesData {
239
+ /** Series name (shown in legend) */
240
+ name: string;
241
+ /** Values by category index; `null` leaves the row empty */
242
+ data: (number | null)[];
243
+ /**
244
+ * Per-point weight (e.g. a sample size) that scales the dot area, by
245
+ * category index
246
+ */
247
+ sizes?: (number | null)[];
248
+ /** Override theme color for this series */
249
+ color?: string;
250
+ /** Per-point label text, by data index */
251
+ labels?: (string | null | undefined)[];
252
+ }
253
+ interface BulletItem {
254
+ /** Row label */
255
+ name: string;
256
+ /** Measured value */
257
+ value: number;
258
+ /** Target value, drawn as a tick */
259
+ target?: number;
260
+ /**
261
+ * Qualitative range boundaries in ascending order, e.g. `[50, 75, 100]`
262
+ * for poor / fair / good. Shaded behind the bar.
263
+ */
264
+ ranges?: number[];
265
+ /** Override the bar colour */
266
+ color?: string;
267
+ /** Label text shown instead of the formatted value */
268
+ label?: string;
269
+ }
270
+ /**
271
+ * An explicit histogram bucket. `start` is inclusive and `end` exclusive,
272
+ * except for the last bucket, which includes its end.
273
+ */
274
+ interface HistogramBin {
275
+ /** Lower bound (inclusive); omit for no lower bound */
276
+ start?: number;
277
+ /** Upper bound (exclusive); omit for no upper bound */
278
+ end?: number;
279
+ /** Axis label (defaults to "start-end") */
280
+ label?: string;
281
+ }
282
+ /**
283
+ * A computed histogram bucket
284
+ */
285
+ interface HistogramBucket {
286
+ /** Axis label */
287
+ label: string;
288
+ /** Lower bound (inclusive), -Infinity when open */
289
+ start: number;
290
+ /** Upper bound, Infinity when open */
291
+ end: number;
292
+ /** Number of values in the bucket */
293
+ count: number;
294
+ }
295
+ interface BoxPlotGroup {
296
+ /** Category label */
297
+ name: string;
298
+ /** Raw observations; non-finite values are ignored */
299
+ values: number[];
300
+ }
301
+ /**
302
+ * Five-number summary of a box plot group
303
+ */
304
+ interface BoxPlotStats {
305
+ /** Lower whisker: the smallest value within 1.5 IQR of Q1 */
306
+ low: number;
307
+ /** First quartile */
308
+ q1: number;
309
+ /** Median */
310
+ median: number;
311
+ /** Third quartile */
312
+ q3: number;
313
+ /** Upper whisker: the largest value within 1.5 IQR of Q3 */
314
+ high: number;
315
+ /** Values beyond the whiskers */
316
+ outliers: number[];
317
+ /** Number of observations */
318
+ count: number;
319
+ /** Arithmetic mean */
320
+ mean: number;
321
+ }
322
+ interface WaterfallStep {
323
+ /** Step label */
324
+ name: string;
325
+ /**
326
+ * Change contributed by this step. For a total step, the value is ignored
327
+ * unless `isTotal` is 'value' (the running total is shown instead).
328
+ */
329
+ value: number;
330
+ /**
331
+ * Draw this step as a total bar from zero: `true` shows the running total
332
+ * up to this step, 'value' shows `value` and resets the running total to it
333
+ */
334
+ isTotal?: boolean | 'value';
335
+ /** Override the bar colour */
336
+ color?: string;
337
+ /** Label text shown instead of the formatted value */
338
+ label?: string;
339
+ }
165
340
 
166
341
  /**
167
342
  * Event parameter types for chart interactions
@@ -272,6 +447,208 @@ interface SankeyEventParams extends BaseEventParams {
272
447
  target?: string;
273
448
  }
274
449
 
450
+ /**
451
+ * Types for customising chart labels, axes, tooltips and legends
452
+ */
453
+ /**
454
+ * A formatter: either an ECharts string template (e.g. `'{b}: {c}'`) or a
455
+ * function returning the text to show.
456
+ */
457
+ type ChartFormatter<P> = string | ((params: P) => string);
458
+ /**
459
+ * Normalised parameters passed to label and tooltip formatter functions
460
+ */
461
+ interface LabelFormatterParams {
462
+ /** Category, slice or node name */
463
+ name: string;
464
+ /** Data value ([x, y] for scatter, [x, y, value] for heatmap) */
465
+ value: number | number[];
466
+ /** Series name */
467
+ seriesName: string;
468
+ /** Series index */
469
+ seriesIndex: number;
470
+ /** Data index within the series */
471
+ dataIndex: number;
472
+ /** Share of the total, for pie, donut and funnel slices */
473
+ percent?: number;
474
+ /** Colour of the data point */
475
+ color?: string;
476
+ /** Per-point label text supplied in the chart data, if any */
477
+ label?: string;
478
+ }
479
+ /**
480
+ * Parameters passed to a tooltip formatter function, one entry per series
481
+ * under the pointer (a single entry for item tooltips)
482
+ */
483
+ interface TooltipFormatterParams extends LabelFormatterParams {
484
+ /** HTML for the coloured dot ECharts draws before each series */
485
+ marker: string;
486
+ /** Axis value under the pointer, for axis tooltips */
487
+ axisValue?: string | number;
488
+ }
489
+ /**
490
+ * Axis customisation for charts with cartesian axes. Refers to the visual
491
+ * axis: `xAxisConfig` is always the horizontal one.
492
+ */
493
+ interface AxisConfig {
494
+ /** Show the axis (defaults to true) */
495
+ show?: boolean;
496
+ /**
497
+ * Axis scale. Category charts default to 'category'; set 'time' (ISO date
498
+ * strings or timestamps as categories) or 'value' to plot categories on a
499
+ * continuous scale. Value axes can use 'log'.
500
+ */
501
+ type?: 'category' | 'time' | 'value' | 'log';
502
+ /** Axis title */
503
+ name?: string;
504
+ /** Where the axis title sits (defaults to 'middle') */
505
+ nameLocation?: 'start' | 'middle' | 'end';
506
+ /** Distance between the axis title and the axis line, in pixels */
507
+ nameGap?: number;
508
+ /** Tick label formatter: a template such as `'{value} kg'` or a function */
509
+ formatter?: string | ((value: string | number, index: number) => string);
510
+ /** Tick label rotation in degrees */
511
+ rotate?: number;
512
+ /** Axis minimum */
513
+ min?: number | 'dataMin';
514
+ /** Axis maximum */
515
+ max?: number | 'dataMax';
516
+ /** Fixed interval between ticks (value axes) */
517
+ interval?: number;
518
+ }
519
+ /** Where the legend is placed */
520
+ type ChartLegendPosition = 'top' | 'right' | 'bottom' | 'left';
521
+ /**
522
+ * Built-in legend customisation
523
+ */
524
+ interface ChartLegendConfig {
525
+ /** Legend placement (defaults to 'bottom') */
526
+ position?: ChartLegendPosition;
527
+ /** Alignment along the legend's edge (defaults to 'center') */
528
+ align?: 'start' | 'center' | 'end';
529
+ /** Item flow; defaults to horizontal for top/bottom, vertical for left/right */
530
+ orient?: 'horizontal' | 'vertical';
531
+ /** Legend marker shape */
532
+ icon?: 'circle' | 'rect' | 'roundRect' | 'line' | 'none';
533
+ /** Item text: a template such as `'{name}'` or a function of the series name */
534
+ formatter?: ChartFormatter<string>;
535
+ /** Page the legend when items overflow instead of wrapping */
536
+ scroll?: boolean;
537
+ }
538
+ /**
539
+ * One entry of a chart legend
540
+ */
541
+ interface LegendItem {
542
+ /** Series, slice or indicator name */
543
+ name: string;
544
+ /** Colour the chart draws the item in */
545
+ color: string;
546
+ /** Whether the item is currently shown */
547
+ visible: boolean;
548
+ }
549
+ /**
550
+ * State and actions handed to a custom legend renderer
551
+ */
552
+ interface LegendRenderProps {
553
+ /** Legend entries in chart order */
554
+ items: LegendItem[];
555
+ /** Requested legend placement */
556
+ position: ChartLegendPosition;
557
+ /** Chart title, for labelling the legend */
558
+ chartTitle: string;
559
+ /** Show or hide an item */
560
+ toggle: (name: string) => void;
561
+ /** Set an item's visibility */
562
+ setVisible: (name: string, visible: boolean) => void;
563
+ /** Show only this item */
564
+ showOnly: (name: string) => void;
565
+ /** Show every item */
566
+ showAll: () => void;
567
+ }
568
+ /**
569
+ * Named number formats for `valueFormat`
570
+ *
571
+ * - `number`: thousand separators, up to 2 decimals
572
+ * - `integer`: rounded, thousand separators
573
+ * - `compact`: 1.2K, 3.4M
574
+ * - `currency`: USD, no cents (`currencyCents` keeps them)
575
+ * - `currencyCents`: USD with cents
576
+ * - `percent`: a 0-1 ratio as a percentage (0.42 -> 42%)
577
+ * - `percentValue`: a value already in percent (42 -> 42%)
578
+ * - `days`: a whole number of days (12 -> "12 days")
579
+ */
580
+ type ValueFormatPreset = 'number' | 'integer' | 'compact' | 'currency' | 'currencyCents' | 'percent' | 'percentValue' | 'days';
581
+ /**
582
+ * How chart values are written in axes, tooltips, data labels and data
583
+ * tables: a preset, `Intl.NumberFormat` options, or a function
584
+ */
585
+ type ValueFormat = ValueFormatPreset | Intl.NumberFormatOptions | ((value: number) => string);
586
+ /**
587
+ * A horizontal or vertical line marking a target, threshold or statistic
588
+ */
589
+ interface ReferenceLine {
590
+ /** A fixed value, or a statistic of the series' values */
591
+ value: number | 'average' | 'median' | 'min' | 'max';
592
+ /** Text shown at the end of the line (defaults to the formatted value) */
593
+ label?: string;
594
+ /**
595
+ * Series the line belongs to, by name (defaults to the first). Statistics
596
+ * are computed from this series, and the line hides with it in the legend.
597
+ */
598
+ series?: string;
599
+ /** Line style (defaults to 'dashed') */
600
+ style?: 'dashed' | 'solid' | 'dotted';
601
+ /** Line colour (defaults to the muted foreground colour) */
602
+ color?: string;
603
+ }
604
+ /**
605
+ * A shaded range of values, e.g. a target band
606
+ */
607
+ interface ReferenceBand {
608
+ /** Range start */
609
+ from: number;
610
+ /** Range end */
611
+ to: number;
612
+ /** Text shown inside the band */
613
+ label?: string;
614
+ /** Fill colour (defaults to a translucent muted colour) */
615
+ color?: string;
616
+ /** Series the band belongs to, by name (defaults to the first) */
617
+ series?: string;
618
+ }
619
+ /**
620
+ * Chart data as a table, for the accessible data table and CSV export
621
+ */
622
+ interface ChartDataTable {
623
+ /** Column headings */
624
+ headers: string[];
625
+ /** Rows of raw cell values */
626
+ rows: (string | number | null)[][];
627
+ /**
628
+ * How each column's numbers are displayed: 'value' uses the chart's
629
+ * `valueFormat`, 'number' plain separators, 'percent' a share already in
630
+ * percent. Text columns ignore it. Defaults to 'value'.
631
+ */
632
+ columns?: ('value' | 'number' | 'percent' | 'text')[];
633
+ }
634
+
635
+ /**
636
+ * Handlers for raw ECharts events, keyed by event name (`'datazoom'`,
637
+ * `'legendselectchanged'`, `'brushselected'`, `'dblclick'`, ...). Handlers
638
+ * receive ECharts' own event parameters.
639
+ */
640
+ type ChartEventHandlers = Record<string, ((params: any) => void) | undefined>;
641
+ /**
642
+ * Export controls shown in the chart's top corner
643
+ */
644
+ interface ChartExportConfig {
645
+ /** Offer a PNG download (defaults to true) */
646
+ image?: boolean;
647
+ /** Offer a CSV download of the chart data (defaults to true) */
648
+ csv?: boolean;
649
+ /** File name without extension (defaults to the chart title) */
650
+ filename?: string;
651
+ }
275
652
  /**
276
653
  * Base chart props shared across all chart components
277
654
  */
@@ -280,16 +657,22 @@ interface BaseChartProps {
280
657
  title: string;
281
658
  /** Optional description for screen readers */
282
659
  description?: string;
283
- /** Chart height in pixels or CSS value */
660
+ /**
661
+ * Chart height in pixels or a CSS value. Charts with one row per category
662
+ * (horizontal bar, bullet, dot plot) also accept 'auto', which sizes the
663
+ * chart to its rows (see `rowHeight`).
664
+ */
284
665
  height?: number | string;
285
- /** Minimum height constraint */
666
+ /** Minimum height in pixels; also bounds an 'auto' height */
286
667
  minHeight?: number;
287
- /** Maximum height constraint */
668
+ /** Maximum height in pixels; also bounds an 'auto' height */
288
669
  maxHeight?: number;
289
670
  /** Show loading skeleton */
290
671
  loading?: boolean;
291
672
  /** Error message to display */
292
673
  error?: string | null;
674
+ /** Show a Retry button on the error state, calling this */
675
+ onRetry?: () => void;
293
676
  /** Message shown when data is empty */
294
677
  emptyMessage?: string;
295
678
  /** Theme preference */
@@ -302,13 +685,105 @@ interface BaseChartProps {
302
685
  showTooltip?: boolean;
303
686
  /** Show grid lines (where applicable) */
304
687
  showGrid?: boolean;
688
+ /**
689
+ * Custom tooltip content: an ECharts template or a function returning HTML.
690
+ * The function always receives an array (one entry for item tooltips).
691
+ * Escape any data you interpolate (see `escapeHtml`).
692
+ */
693
+ tooltipFormatter?: ChartFormatter<TooltipFormatterParams[]>;
694
+ /** Format the values in the default tooltip, e.g. as currency */
695
+ tooltipValueFormatter?: (value: number) => string;
696
+ /**
697
+ * How values are written in value axes, tooltips, data labels and the data
698
+ * table: a preset such as 'currency' or 'percent', `Intl.NumberFormat`
699
+ * options, or a function. More specific formatters (`tooltipValueFormatter`,
700
+ * `labelFormatter`, an axis `formatter`) take precedence.
701
+ */
702
+ valueFormat?: ValueFormat;
703
+ /** Locale for `valueFormat` (defaults to 'en-US') */
704
+ locale?: string;
705
+ /**
706
+ * Raw ECharts option deep-merged over the generated one, for anything the
707
+ * props do not cover. Arrays such as `series` merge by index. Mark lines,
708
+ * mark areas, data zoom, datasets and graphics are always available.
709
+ */
710
+ option?: EChartsOption;
711
+ /**
712
+ * Called with the ECharts instance whenever it is created (on mount and on
713
+ * a theme change), for imperative access such as `getDataURL`
714
+ */
715
+ onReady?: (chart: EChartsType) => void;
716
+ /** Raw ECharts event handlers, keyed by event name */
717
+ events?: ChartEventHandlers;
718
+ /**
719
+ * Render the chart data as a table: 'sr-only' (the default) for screen
720
+ * readers only, `true` for a visible "Show data" toggle, `false` for none
721
+ */
722
+ showDataTable?: boolean | 'sr-only';
723
+ /** Show download buttons (PNG image and CSV data) */
724
+ exportable?: boolean | ChartExportConfig;
725
+ /** Fill series with patterns as well as colour, for colour-blind readers */
726
+ patterns?: boolean;
305
727
  /** Custom CSS class */
306
728
  class?: string;
307
729
  }
730
+ /**
731
+ * Props for charts with a legend
732
+ */
733
+ interface LegendChartProps {
734
+ /** Built-in legend placement and formatting */
735
+ legend?: ChartLegendConfig;
736
+ /** Called when legend items are shown or hidden, with every item's visibility */
737
+ onLegendChange?: (visible: Record<string, boolean>) => void;
738
+ }
739
+ /**
740
+ * Props for charts with data labels
741
+ */
742
+ interface LabelChartProps {
743
+ /** Data label text: an ECharts template or a function */
744
+ labelFormatter?: ChartFormatter<LabelFormatterParams>;
745
+ }
746
+ /**
747
+ * Props for charts with cartesian axes
748
+ */
749
+ interface AxisChartProps {
750
+ /** Horizontal axis customisation */
751
+ xAxisConfig?: AxisConfig;
752
+ /** Vertical axis customisation */
753
+ yAxisConfig?: AxisConfig;
754
+ }
755
+ /**
756
+ * Props for charts with value axes that can carry reference marks
757
+ */
758
+ interface ReferenceChartProps {
759
+ /** Lines marking targets, thresholds or averages */
760
+ referenceLines?: ReferenceLine[];
761
+ /** Shaded value ranges */
762
+ referenceBands?: ReferenceBand[];
763
+ }
764
+ /**
765
+ * Props for charts with a category axis that can be zoomed
766
+ */
767
+ interface ZoomChartProps {
768
+ /**
769
+ * Let users zoom and pan the category axis: 'inside' (wheel and drag),
770
+ * 'slider' (a range slider below the chart) or `true` for both
771
+ */
772
+ dataZoom?: boolean | 'inside' | 'slider';
773
+ }
774
+ /**
775
+ * Props for charts whose height can follow their row count
776
+ */
777
+ interface RowHeightProps {
778
+ /** Height per category row for `height="auto"` (defaults to 28) */
779
+ rowHeight?: number;
780
+ }
308
781
  /**
309
782
  * Line chart specific props
310
783
  */
311
- interface LineChartProps extends BaseChartProps {
784
+ interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
785
+ /** Show data labels */
786
+ showLabels?: boolean;
312
787
  /** Chart data */
313
788
  data: LineChartData;
314
789
  /** Use smooth curved lines */
@@ -317,8 +792,10 @@ interface LineChartProps extends BaseChartProps {
317
792
  areaFilled?: boolean;
318
793
  /** Show data points on the line */
319
794
  showDataPoints?: boolean;
320
- /** Stack multiple series */
321
- stacked?: boolean;
795
+ /** Stack multiple series; 'percent' stacks each category's share of 100% */
796
+ stacked?: boolean | 'percent';
797
+ /** Draw the line across missing (`null`) values instead of leaving a gap */
798
+ connectNulls?: boolean;
322
799
  /** Click event handler */
323
800
  onClick?: (params: DataPointEventParams) => void;
324
801
  /** Hover event handler */
@@ -327,22 +804,27 @@ interface LineChartProps extends BaseChartProps {
327
804
  /**
328
805
  * Bar chart specific props
329
806
  */
330
- interface BarChartProps extends BaseChartProps {
807
+ interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
331
808
  /** Chart data */
332
809
  data: BarChartData;
333
- /** Bar orientation */
810
+ /**
811
+ * Bar orientation. Horizontal bars list categories top to bottom in data
812
+ * order.
813
+ */
334
814
  orientation?: 'vertical' | 'horizontal';
335
- /** Stack multiple series */
336
- stacked?: boolean;
815
+ /** Stack multiple series; 'percent' stacks each category's share of 100% */
816
+ stacked?: boolean | 'percent';
337
817
  /** Show value labels on bars */
338
818
  showValues?: boolean;
339
819
  /** Click event handler */
340
820
  onClick?: (params: DataPointEventParams) => void;
821
+ /** Hover event handler */
822
+ onHover?: (params: DataPointEventParams) => void;
341
823
  }
342
824
  /**
343
825
  * Pie chart specific props
344
826
  */
345
- interface PieChartProps extends BaseChartProps {
827
+ interface PieChartProps extends BaseChartProps, LegendChartProps, LabelChartProps {
346
828
  /** Chart data */
347
829
  data: PieSliceData[];
348
830
  /** Show slice labels */
@@ -368,22 +850,30 @@ interface DonutChartProps extends Omit<PieChartProps, 'innerRadius'> {
368
850
  /**
369
851
  * Area chart specific props
370
852
  */
371
- interface AreaChartProps extends BaseChartProps {
853
+ interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
854
+ /** Show data labels */
855
+ showLabels?: boolean;
372
856
  /** Chart data */
373
857
  data: AreaChartData;
374
858
  /** Use smooth curved lines */
375
859
  smooth?: boolean;
376
- /** Stack multiple series */
377
- stacked?: boolean;
860
+ /** Stack multiple series; 'percent' stacks each category's share of 100% */
861
+ stacked?: boolean | 'percent';
862
+ /** Draw the area across missing (`null`) values instead of leaving a gap */
863
+ connectNulls?: boolean;
378
864
  /** Use gradient fill */
379
865
  gradient?: boolean;
380
866
  /** Click event handler */
381
867
  onClick?: (params: DataPointEventParams) => void;
868
+ /** Hover event handler */
869
+ onHover?: (params: DataPointEventParams) => void;
382
870
  }
383
871
  /**
384
872
  * Scatter chart specific props
385
873
  */
386
- interface ScatterChartProps extends BaseChartProps {
874
+ interface ScatterChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps {
875
+ /** Show data labels */
876
+ showLabels?: boolean;
387
877
  /** Chart data */
388
878
  data: ScatterChartData;
389
879
  /** Show trend/regression line */
@@ -392,22 +882,28 @@ interface ScatterChartProps extends BaseChartProps {
392
882
  symbolSize?: number | ((value: number[]) => number);
393
883
  /** Click event handler */
394
884
  onClick?: (params: DataPointEventParams) => void;
885
+ /** Hover event handler */
886
+ onHover?: (params: DataPointEventParams) => void;
395
887
  }
396
888
  /**
397
889
  * Radar chart specific props
398
890
  */
399
- interface RadarChartProps extends BaseChartProps {
891
+ interface RadarChartProps extends BaseChartProps, LegendChartProps, LabelChartProps {
892
+ /** Show data labels */
893
+ showLabels?: boolean;
400
894
  /** Chart data */
401
895
  data: RadarChartData;
402
896
  /** Radar indicators/dimensions */
403
897
  indicators: RadarIndicator[];
404
898
  /** Radar shape */
405
899
  shape?: 'polygon' | 'circle';
900
+ /** Click event handler */
901
+ onClick?: (params: DataPointEventParams) => void;
406
902
  }
407
903
  /**
408
904
  * Funnel chart specific props
409
905
  */
410
- interface FunnelChartProps extends BaseChartProps {
906
+ interface FunnelChartProps extends BaseChartProps, LegendChartProps, LabelChartProps {
411
907
  /** Chart data */
412
908
  data: FunnelSliceData[];
413
909
  /** Sort order */
@@ -433,13 +929,15 @@ interface GaugeChartProps extends BaseChartProps {
433
929
  splitNumber?: number;
434
930
  /** Show progress arc */
435
931
  showProgress?: boolean;
436
- /** Value format function */
932
+ /** Value format function (takes precedence over `valueFormat`) */
437
933
  formatValue?: (value: number) => string;
934
+ /** Click event handler */
935
+ onClick?: (params: DataPointEventParams) => void;
438
936
  }
439
937
  /**
440
938
  * Heatmap chart specific props
441
939
  */
442
- interface HeatmapChartProps extends BaseChartProps {
940
+ interface HeatmapChartProps extends BaseChartProps, LabelChartProps, AxisChartProps {
443
941
  /** Chart data */
444
942
  data: HeatmapData;
445
943
  /** X-axis labels */
@@ -454,7 +952,7 @@ interface HeatmapChartProps extends BaseChartProps {
454
952
  /**
455
953
  * Treemap chart specific props
456
954
  */
457
- interface TreemapChartProps extends BaseChartProps {
955
+ interface TreemapChartProps extends BaseChartProps, LabelChartProps {
458
956
  /** Hierarchical data */
459
957
  data: TreemapNode[];
460
958
  /** Level configurations */
@@ -465,18 +963,23 @@ interface TreemapChartProps extends BaseChartProps {
465
963
  /**
466
964
  * Candlestick chart specific props
467
965
  */
468
- interface CandlestickChartProps extends BaseChartProps {
966
+ interface CandlestickChartProps extends BaseChartProps, AxisChartProps {
469
967
  /** Chart data */
470
968
  data: CandlestickData;
471
969
  /** Show volume bars */
472
970
  showVolume?: boolean;
971
+ /**
972
+ * Initial zoom window start, as a percentage of the dates (defaults to 80,
973
+ * showing the latest fifth). 0 shows everything.
974
+ */
975
+ zoomStart?: number;
473
976
  /** Click event handler */
474
977
  onClick?: (params: CandlestickEventParams) => void;
475
978
  }
476
979
  /**
477
980
  * Sankey chart specific props
478
981
  */
479
- interface SankeyChartProps extends BaseChartProps {
982
+ interface SankeyChartProps extends BaseChartProps, LabelChartProps {
480
983
  /** Chart data with nodes and links */
481
984
  data: SankeyData;
482
985
  /** Flow orientation */
@@ -484,5 +987,207 @@ interface SankeyChartProps extends BaseChartProps {
484
987
  /** Click event handler */
485
988
  onClick?: (params: SankeyEventParams) => void;
486
989
  }
990
+ /**
991
+ * Combo chart: bars, lines and areas over shared categories, on one or two
992
+ * value axes
993
+ */
994
+ interface ComboChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, ReferenceChartProps, ZoomChartProps {
995
+ /** Chart data */
996
+ data: ComboChartData;
997
+ /** Horizontal (category) axis customisation */
998
+ xAxisConfig?: AxisConfig;
999
+ /** Left (primary) value axis customisation */
1000
+ yAxisConfig?: AxisConfig;
1001
+ /** Right (secondary) value axis customisation */
1002
+ secondaryYAxisConfig?: AxisConfig;
1003
+ /** Value format for series on the secondary axis (defaults to `valueFormat`) */
1004
+ secondaryValueFormat?: ValueFormat;
1005
+ /** Stack bar series that share a stack id (or all bars when true) */
1006
+ stacked?: boolean;
1007
+ /** Use smooth curved lines */
1008
+ smooth?: boolean;
1009
+ /** Show data labels */
1010
+ showLabels?: boolean;
1011
+ /** Draw lines across missing (`null`) values */
1012
+ connectNulls?: boolean;
1013
+ /** Click event handler */
1014
+ onClick?: (params: DataPointEventParams) => void;
1015
+ /** Hover event handler */
1016
+ onHover?: (params: DataPointEventParams) => void;
1017
+ }
1018
+ /**
1019
+ * Dot plot: one row per category with a dot per series, on a value axis that
1020
+ * need not start at zero
1021
+ */
1022
+ interface DotPlotChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, ReferenceChartProps, RowHeightProps {
1023
+ /** Chart data */
1024
+ data: DotPlotChartData;
1025
+ /** Value axis customisation (min/max default to the data range) */
1026
+ valueAxisConfig?: AxisConfig;
1027
+ /** Category axis customisation */
1028
+ categoryAxisConfig?: AxisConfig;
1029
+ /** Dot diameter in pixels, or the [smallest, largest] range when sizes are set */
1030
+ dotSize?: number | [number, number];
1031
+ /** Draw a line between the dots of a row (for comparing two series) */
1032
+ connect?: boolean;
1033
+ /** Show value labels beside the dots */
1034
+ showLabels?: boolean;
1035
+ /** Click event handler */
1036
+ onClick?: (params: DataPointEventParams) => void;
1037
+ }
1038
+ /**
1039
+ * Bullet chart: a measured bar per row against a target tick and shaded
1040
+ * qualitative ranges
1041
+ */
1042
+ interface BulletChartProps extends BaseChartProps, LabelChartProps, RowHeightProps {
1043
+ /** One row per item */
1044
+ data: BulletItem[];
1045
+ /** Value axis customisation */
1046
+ valueAxisConfig?: AxisConfig;
1047
+ /** Show value labels at the end of each bar */
1048
+ showLabels?: boolean;
1049
+ /** Click event handler */
1050
+ onClick?: (params: DataPointEventParams) => void;
1051
+ }
1052
+ /**
1053
+ * Histogram: the distribution of raw values across buckets
1054
+ */
1055
+ interface HistogramChartProps extends BaseChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps {
1056
+ /**
1057
+ * Raw observations; non-finite values are ignored. `valueFormat` writes
1058
+ * the bucket bounds; counts are plain numbers.
1059
+ */
1060
+ values: number[];
1061
+ /**
1062
+ * Buckets: a count of equal-width buckets, or explicit buckets such as
1063
+ * aging ranges (defaults to Sturges' rule)
1064
+ */
1065
+ bins?: number | HistogramBin[];
1066
+ /** Width of equal buckets (takes precedence over a bin count) */
1067
+ binWidth?: number;
1068
+ /** Series name, shown in tooltips (defaults to 'Count') */
1069
+ seriesName?: string;
1070
+ /** Bar colour */
1071
+ color?: string;
1072
+ /** Show counts above the bars */
1073
+ showLabels?: boolean;
1074
+ /** Click event handler; `name` is the bucket label and `value` its count */
1075
+ onClick?: (params: DataPointEventParams) => void;
1076
+ }
1077
+ /**
1078
+ * Box plot: the spread of raw values per category (quartiles, whiskers at
1079
+ * 1.5 IQR, outliers)
1080
+ */
1081
+ interface BoxPlotChartProps extends BaseChartProps, AxisChartProps, ReferenceChartProps {
1082
+ /** One box per group */
1083
+ data: BoxPlotGroup[];
1084
+ /** Box orientation */
1085
+ orientation?: 'vertical' | 'horizontal';
1086
+ /** Draw values beyond the whiskers as dots (defaults to true) */
1087
+ showOutliers?: boolean;
1088
+ /** Box colour */
1089
+ color?: string;
1090
+ /** Click event handler; `value` is [low, q1, median, q3, high] */
1091
+ onClick?: (params: DataPointEventParams) => void;
1092
+ }
1093
+ /**
1094
+ * Waterfall: how a starting value moves through increases and decreases to
1095
+ * a total
1096
+ */
1097
+ interface WaterfallChartProps extends BaseChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps {
1098
+ /** Steps in order */
1099
+ data: WaterfallStep[];
1100
+ /** Show each step's change above its bar (defaults to true) */
1101
+ showLabels?: boolean;
1102
+ /** Colour for increases (defaults to the success colour) */
1103
+ increaseColor?: string;
1104
+ /** Colour for decreases (defaults to the destructive colour) */
1105
+ decreaseColor?: string;
1106
+ /** Colour for totals (defaults to the first series colour) */
1107
+ totalColor?: string;
1108
+ /** Click event handler; `value` is the step's change (or total) */
1109
+ onClick?: (params: DataPointEventParams) => void;
1110
+ }
1111
+ /**
1112
+ * Sparkline: a small, axis-free trend line drawn as SVG
1113
+ */
1114
+ interface SparklineProps {
1115
+ /** Values in order; `null` leaves a gap */
1116
+ data: (number | null)[];
1117
+ /** How the values are drawn */
1118
+ variant?: 'line' | 'area' | 'bar';
1119
+ /** Width in pixels, or a CSS value (defaults to '100%') */
1120
+ width?: number | string;
1121
+ /** Height in pixels (defaults to 32) */
1122
+ height?: number;
1123
+ /** Stroke/fill colour (defaults to the first chart colour, `chart-1`) */
1124
+ color?: string;
1125
+ /** Mark the last value with a dot (defaults to true for line and area) */
1126
+ showLastPoint?: boolean;
1127
+ /** A horizontal reference line, e.g. a target or average */
1128
+ referenceLine?: number | 'average';
1129
+ /** Lower bound of the scale (defaults to the smallest value, or 0 for bars) */
1130
+ min?: number;
1131
+ /** Upper bound of the scale (defaults to the largest value) */
1132
+ max?: number;
1133
+ /**
1134
+ * Accessible label; when omitted the sparkline is decorative and hidden
1135
+ * from screen readers
1136
+ */
1137
+ label?: string;
1138
+ /** Custom CSS class */
1139
+ class?: string;
1140
+ }
1141
+ /**
1142
+ * A change between two periods, for `StatCard`
1143
+ */
1144
+ interface StatDelta {
1145
+ /** The value being compared against (e.g. last year's) */
1146
+ previous: number | null | undefined;
1147
+ /** The current value (defaults to the card's `value` when it is a number) */
1148
+ current?: number | null;
1149
+ /**
1150
+ * How the change is shown: 'percent' (+12%), 'absolute' (+12, using the
1151
+ * card's value format) or 'both' (defaults to 'percent')
1152
+ */
1153
+ display?: 'percent' | 'absolute' | 'both';
1154
+ /** Which direction is good, for colouring (defaults to 'up'); 'none' stays neutral */
1155
+ goodWhen?: 'up' | 'down' | 'none';
1156
+ /** Text after the change, e.g. 'vs last year' */
1157
+ label?: string;
1158
+ }
1159
+ /**
1160
+ * Stat card: a headline metric with its change and trend
1161
+ */
1162
+ interface StatCardProps {
1163
+ /** Metric name */
1164
+ label: string;
1165
+ /** The value; numbers are formatted with `valueFormat` */
1166
+ value: number | string | null | undefined;
1167
+ /** How a numeric value is written */
1168
+ valueFormat?: ValueFormat;
1169
+ /** Locale for `valueFormat` (defaults to 'en-US') */
1170
+ locale?: string;
1171
+ /** Change against a previous value */
1172
+ delta?: StatDelta;
1173
+ /** Secondary text under the value */
1174
+ hint?: string;
1175
+ /** Definition of the metric, shown in an info tooltip beside the label */
1176
+ definition?: string;
1177
+ /** Make the card a link */
1178
+ href?: string;
1179
+ /** Trend values, drawn as a sparkline */
1180
+ trend?: (number | null)[];
1181
+ /** Sparkline variant */
1182
+ trendVariant?: SparklineProps['variant'];
1183
+ /** Tone of the value itself, e.g. to flag a breached threshold */
1184
+ tone?: 'default' | 'success' | 'warning' | 'destructive';
1185
+ /** Text shown when the value is missing (defaults to '—') */
1186
+ emptyValue?: string;
1187
+ /** Show a loading placeholder */
1188
+ loading?: boolean;
1189
+ /** Custom CSS class */
1190
+ class?: string;
1191
+ }
487
1192
 
488
- export type { AreaChartData, AreaChartProps, AreaSeriesData, BarChartData, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, DataPointEventParams, DonutChartProps, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, LineChartData, LineChartProps, LineSeriesData, PieChartProps, PieSliceData, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartData, ScatterChartProps, ScatterSeriesData, SliceEventParams, TreemapChartProps, TreemapEventParams, TreemapLevel, TreemapNode };
1193
+ export type { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, AxisConfig, BarChartData, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, BoxPlotChartProps, BoxPlotGroup, BoxPlotStats, BulletChartProps, BulletItem, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, CategoryChartData, CategorySeriesData, ChartDataTable, ChartEventHandlers, ChartExportConfig, ChartFormatter, ChartLegendConfig, ChartLegendPosition, ComboChartData, ComboChartProps, ComboSeriesData, DataPointEventParams, DonutChartProps, DotPlotChartData, DotPlotChartProps, DotPlotSeriesData, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, HistogramBin, HistogramBucket, HistogramChartProps, LabelChartProps, LabelFormatterParams, LegendChartProps, LegendItem, LegendRenderProps, LineChartData, LineChartProps, LineSeriesData, PieChartProps, PieSliceData, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, ReferenceBand, ReferenceChartProps, ReferenceLine, RowHeightProps, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartData, ScatterChartProps, ScatterSeriesData, SliceEventParams, SparklineProps, StatCardProps, StatDelta, TooltipFormatterParams, TreemapChartProps, TreemapEventParams, TreemapLevel, TreemapNode, ValueFormat, ValueFormatPreset, WaterfallChartProps, WaterfallStep, ZoomChartProps };