@classic-homes/charts-core 0.2.0 → 0.3.1

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,4 +1,5 @@
1
1
  import { EChartsOption } from 'echarts';
2
+ import { EChartsType } from 'echarts/core';
2
3
 
3
4
  /**
4
5
  * Data structure types for all chart components
@@ -12,12 +13,17 @@ interface LineChartData {
12
13
  interface LineSeriesData {
13
14
  /** Series name (shown in legend) */
14
15
  name: string;
15
- /** Data values corresponding to categories */
16
- data: number[];
16
+ /** Data values corresponding to categories; `null` marks a missing value (a gap) */
17
+ data: (number | null)[];
17
18
  /** Override theme color for this series */
18
19
  color?: string;
19
20
  /** Per-point label text, by data index (shown on those points; templates allowed) */
20
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;
21
27
  }
22
28
  interface BarChartData {
23
29
  /** Category labels */
@@ -28,12 +34,17 @@ interface BarChartData {
28
34
  interface BarSeriesData {
29
35
  /** Series name (shown in legend) */
30
36
  name: string;
31
- /** Data values corresponding to categories */
32
- data: number[];
37
+ /** Data values corresponding to categories; `null` marks a missing value (a gap) */
38
+ data: (number | null)[];
33
39
  /** Override theme color for this series */
34
40
  color?: string;
35
41
  /** Per-point label text, by data index (shown on those points; templates allowed) */
36
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;
37
48
  }
38
49
  interface PieSliceData {
39
50
  /** Slice name (shown in legend/tooltip) */
@@ -54,12 +65,17 @@ interface AreaChartData {
54
65
  interface AreaSeriesData {
55
66
  /** Series name (shown in legend) */
56
67
  name: string;
57
- /** Data values corresponding to categories */
58
- data: number[];
68
+ /** Data values corresponding to categories; `null` marks a missing value (a gap) */
69
+ data: (number | null)[];
59
70
  /** Override theme color for this series */
60
71
  color?: string;
61
72
  /** Per-point label text, by data index (shown on those points; templates allowed) */
62
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;
63
79
  }
64
80
  interface ScatterChartData {
65
81
  /** Data series */
@@ -180,6 +196,147 @@ interface SankeyLink {
180
196
  /** Flow value */
181
197
  value: number;
182
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
+ }
183
340
 
184
341
  /**
185
342
  * Event parameter types for chart interactions
@@ -336,6 +493,12 @@ interface TooltipFormatterParams extends LabelFormatterParams {
336
493
  interface AxisConfig {
337
494
  /** Show the axis (defaults to true) */
338
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';
339
502
  /** Axis title */
340
503
  name?: string;
341
504
  /** Where the axis title sits (defaults to 'middle') */
@@ -402,7 +565,90 @@ interface LegendRenderProps {
402
565
  /** Show every item */
403
566
  showAll: () => void;
404
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
+ }
405
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
+ }
406
652
  /**
407
653
  * Base chart props shared across all chart components
408
654
  */
@@ -411,16 +657,22 @@ interface BaseChartProps {
411
657
  title: string;
412
658
  /** Optional description for screen readers */
413
659
  description?: string;
414
- /** 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
+ */
415
665
  height?: number | string;
416
- /** Minimum height constraint */
666
+ /** Minimum height in pixels; also bounds an 'auto' height */
417
667
  minHeight?: number;
418
- /** Maximum height constraint */
668
+ /** Maximum height in pixels; also bounds an 'auto' height */
419
669
  maxHeight?: number;
420
670
  /** Show loading skeleton */
421
671
  loading?: boolean;
422
672
  /** Error message to display */
423
673
  error?: string | null;
674
+ /** Show a Retry button on the error state, calling this */
675
+ onRetry?: () => void;
424
676
  /** Message shown when data is empty */
425
677
  emptyMessage?: string;
426
678
  /** Theme preference */
@@ -441,11 +693,37 @@ interface BaseChartProps {
441
693
  tooltipFormatter?: ChartFormatter<TooltipFormatterParams[]>;
442
694
  /** Format the values in the default tooltip, e.g. as currency */
443
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;
444
705
  /**
445
706
  * Raw ECharts option deep-merged over the generated one, for anything the
446
- * props do not cover. Arrays such as `series` merge by index.
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.
447
709
  */
448
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;
449
727
  /** Custom CSS class */
450
728
  class?: string;
451
729
  }
@@ -474,10 +752,36 @@ interface AxisChartProps {
474
752
  /** Vertical axis customisation */
475
753
  yAxisConfig?: AxisConfig;
476
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
+ }
477
781
  /**
478
782
  * Line chart specific props
479
783
  */
480
- interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps {
784
+ interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
481
785
  /** Show data labels */
482
786
  showLabels?: boolean;
483
787
  /** Chart data */
@@ -488,8 +792,10 @@ interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
488
792
  areaFilled?: boolean;
489
793
  /** Show data points on the line */
490
794
  showDataPoints?: boolean;
491
- /** Stack multiple series */
492
- 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;
493
799
  /** Click event handler */
494
800
  onClick?: (params: DataPointEventParams) => void;
495
801
  /** Hover event handler */
@@ -498,17 +804,22 @@ interface LineChartProps extends BaseChartProps, LegendChartProps, LabelChartPro
498
804
  /**
499
805
  * Bar chart specific props
500
806
  */
501
- interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps {
807
+ interface BarChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps, RowHeightProps {
502
808
  /** Chart data */
503
809
  data: BarChartData;
504
- /** Bar orientation */
810
+ /**
811
+ * Bar orientation. Horizontal bars list categories top to bottom in data
812
+ * order.
813
+ */
505
814
  orientation?: 'vertical' | 'horizontal';
506
- /** Stack multiple series */
507
- stacked?: boolean;
815
+ /** Stack multiple series; 'percent' stacks each category's share of 100% */
816
+ stacked?: boolean | 'percent';
508
817
  /** Show value labels on bars */
509
818
  showValues?: boolean;
510
819
  /** Click event handler */
511
820
  onClick?: (params: DataPointEventParams) => void;
821
+ /** Hover event handler */
822
+ onHover?: (params: DataPointEventParams) => void;
512
823
  }
513
824
  /**
514
825
  * Pie chart specific props
@@ -539,24 +850,28 @@ interface DonutChartProps extends Omit<PieChartProps, 'innerRadius'> {
539
850
  /**
540
851
  * Area chart specific props
541
852
  */
542
- interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps {
853
+ interface AreaChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps, ZoomChartProps {
543
854
  /** Show data labels */
544
855
  showLabels?: boolean;
545
856
  /** Chart data */
546
857
  data: AreaChartData;
547
858
  /** Use smooth curved lines */
548
859
  smooth?: boolean;
549
- /** Stack multiple series */
550
- 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;
551
864
  /** Use gradient fill */
552
865
  gradient?: boolean;
553
866
  /** Click event handler */
554
867
  onClick?: (params: DataPointEventParams) => void;
868
+ /** Hover event handler */
869
+ onHover?: (params: DataPointEventParams) => void;
555
870
  }
556
871
  /**
557
872
  * Scatter chart specific props
558
873
  */
559
- interface ScatterChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps {
874
+ interface ScatterChartProps extends BaseChartProps, LegendChartProps, LabelChartProps, AxisChartProps, ReferenceChartProps {
560
875
  /** Show data labels */
561
876
  showLabels?: boolean;
562
877
  /** Chart data */
@@ -567,6 +882,8 @@ interface ScatterChartProps extends BaseChartProps, LegendChartProps, LabelChart
567
882
  symbolSize?: number | ((value: number[]) => number);
568
883
  /** Click event handler */
569
884
  onClick?: (params: DataPointEventParams) => void;
885
+ /** Hover event handler */
886
+ onHover?: (params: DataPointEventParams) => void;
570
887
  }
571
888
  /**
572
889
  * Radar chart specific props
@@ -580,6 +897,8 @@ interface RadarChartProps extends BaseChartProps, LegendChartProps, LabelChartPr
580
897
  indicators: RadarIndicator[];
581
898
  /** Radar shape */
582
899
  shape?: 'polygon' | 'circle';
900
+ /** Click event handler */
901
+ onClick?: (params: DataPointEventParams) => void;
583
902
  }
584
903
  /**
585
904
  * Funnel chart specific props
@@ -610,8 +929,10 @@ interface GaugeChartProps extends BaseChartProps {
610
929
  splitNumber?: number;
611
930
  /** Show progress arc */
612
931
  showProgress?: boolean;
613
- /** Value format function */
932
+ /** Value format function (takes precedence over `valueFormat`) */
614
933
  formatValue?: (value: number) => string;
934
+ /** Click event handler */
935
+ onClick?: (params: DataPointEventParams) => void;
615
936
  }
616
937
  /**
617
938
  * Heatmap chart specific props
@@ -647,6 +968,11 @@ interface CandlestickChartProps extends BaseChartProps, AxisChartProps {
647
968
  data: CandlestickData;
648
969
  /** Show volume bars */
649
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;
650
976
  /** Click event handler */
651
977
  onClick?: (params: CandlestickEventParams) => void;
652
978
  }
@@ -661,5 +987,207 @@ interface SankeyChartProps extends BaseChartProps, LabelChartProps {
661
987
  /** Click event handler */
662
988
  onClick?: (params: SankeyEventParams) => void;
663
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
+ }
664
1192
 
665
- export type { AreaChartData, AreaChartProps, AreaSeriesData, AxisChartProps, AxisConfig, BarChartData, BarChartProps, BarSeriesData, BaseChartProps, BaseEventParams, CandlestickChartProps, CandlestickData, CandlestickEventParams, CandlestickItem, ChartFormatter, ChartLegendConfig, ChartLegendPosition, DataPointEventParams, DonutChartProps, FunnelChartProps, FunnelSliceData, GaugeChartProps, HeatmapChartProps, HeatmapData, HeatmapEventParams, LabelChartProps, LabelFormatterParams, LegendChartProps, LegendItem, LegendRenderProps, LineChartData, LineChartProps, LineSeriesData, PieChartProps, PieSliceData, RadarChartData, RadarChartProps, RadarIndicator, RadarSeriesData, SankeyChartProps, SankeyData, SankeyEventParams, SankeyLink, SankeyNode, ScatterChartData, ScatterChartProps, ScatterSeriesData, SliceEventParams, TooltipFormatterParams, 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 };