@lilt-ui/charts 0.1.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.
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/THIRD_PARTY_NOTICES.md +25 -0
- package/dist/activity-ring.d.ts +44 -0
- package/dist/analysis-BLLWEKBw.js +105 -0
- package/dist/cards/activity-ring-card.d.ts +60 -0
- package/dist/cards/area-chart-card.d.ts +19 -0
- package/dist/cards/area-chart-card.typecheck.d.ts +9 -0
- package/dist/cards/bar-chart-card.d.ts +34 -0
- package/dist/cards/cartesian-card.d.ts +206 -0
- package/dist/cards/chart-card.d.ts +77 -0
- package/dist/cards/combo-chart-card.d.ts +51 -0
- package/dist/cards/format.d.ts +36 -0
- package/dist/cards/funnel-chart-card.d.ts +62 -0
- package/dist/cards/heatmap-chart-card.d.ts +107 -0
- package/dist/cards/horizontal-bar-chart-card.d.ts +60 -0
- package/dist/cards/keys.d.ts +19 -0
- package/dist/cards/line-chart-card.d.ts +19 -0
- package/dist/cards/progress-card.d.ts +55 -0
- package/dist/cards/radar-chart-card.d.ts +93 -0
- package/dist/cards/radial-chart-card.d.ts +79 -0
- package/dist/cards/rank.d.ts +21 -0
- package/dist/cards/sankey-chart-card.d.ts +69 -0
- package/dist/cards/scatter-chart-card.d.ts +91 -0
- package/dist/cards/slope-chart-card.d.ts +73 -0
- package/dist/cards/stat-card.d.ts +68 -0
- package/dist/chart-context.d.ts +102 -0
- package/dist/chart-plot.d.ts +13 -0
- package/dist/chart.d.ts +17 -0
- package/dist/data/chart-data.d.ts +24 -0
- package/dist/data.d.ts +5 -0
- package/dist/data.js +2 -0
- package/dist/engine/analysis.d.ts +11 -0
- package/dist/engine/bars.d.ts +38 -0
- package/dist/engine/comparison.d.ts +3 -0
- package/dist/engine/composition.d.ts +6 -0
- package/dist/engine/domains.d.ts +13 -0
- package/dist/engine/geometry.d.ts +73 -0
- package/dist/engine/lifecycle.d.ts +10 -0
- package/dist/engine/lookup.d.ts +3 -0
- package/dist/engine/normalize.d.ts +21 -0
- package/dist/engine/ranking.d.ts +20 -0
- package/dist/engine/sankey.d.ts +36 -0
- package/dist/engine/scatter.d.ts +15 -0
- package/dist/engine/slope.d.ts +46 -0
- package/dist/engine/stack.d.ts +11 -0
- package/dist/export-chart-svg.d.ts +8 -0
- package/dist/index.d.ts +73 -0
- package/dist/index.js +11309 -0
- package/dist/interaction/adaptive-readout.d.ts +16 -0
- package/dist/interaction/axis-cursor.d.ts +30 -0
- package/dist/interaction/brush-gesture.d.ts +15 -0
- package/dist/interaction/brush-view.d.ts +12 -0
- package/dist/interaction/chart-controller.d.ts +6 -0
- package/dist/interaction/chart-sync.d.ts +35 -0
- package/dist/interaction/comparison-answer.d.ts +11 -0
- package/dist/interaction/comparison-layer.d.ts +19 -0
- package/dist/interaction/comparison-tooltip.d.ts +14 -0
- package/dist/interaction/focus-overview.d.ts +10 -0
- package/dist/interaction/inspection-layer.d.ts +29 -0
- package/dist/interaction/legend.d.ts +50 -0
- package/dist/interaction/pin-marker.d.ts +12 -0
- package/dist/interaction/tooltip-context.d.ts +4 -0
- package/dist/interaction/tooltip-view.d.ts +26 -0
- package/dist/interaction/tooltip.d.ts +10 -0
- package/dist/interaction/use-category-state.d.ts +24 -0
- package/dist/interaction/use-pinned-selection.d.ts +3 -0
- package/dist/interaction/value-legend.d.ts +32 -0
- package/dist/interaction/visibility.d.ts +8 -0
- package/dist/lifecycle/loading-layer.d.ts +38 -0
- package/dist/lifecycle/skeleton-sheen.d.ts +18 -0
- package/dist/lifecycle/status-content.d.ts +6 -0
- package/dist/model/cartesian-model.d.ts +132 -0
- package/dist/model/cartesian-model.typecheck.d.ts +1 -0
- package/dist/model/use-chart-state.d.ts +6 -0
- package/dist/motion/animated-number.d.ts +54 -0
- package/dist/motion/bounded-text.d.ts +13 -0
- package/dist/motion/entrance.d.ts +9 -0
- package/dist/motion/number-format.d.ts +4 -0
- package/dist/motion/use-chart-motion.d.ts +10 -0
- package/dist/motion/use-focus-domain.d.ts +7 -0
- package/dist/motion/use-glide.d.ts +13 -0
- package/dist/motion/use-series-weights.d.ts +2 -0
- package/dist/paint.d.ts +11 -0
- package/dist/primitives/annotations.d.ts +4 -0
- package/dist/primitives/area.d.ts +8 -0
- package/dist/primitives/axes.d.ts +9 -0
- package/dist/primitives/bar-shape.d.ts +39 -0
- package/dist/primitives/bar.d.ts +7 -0
- package/dist/primitives/change-comparison.d.ts +3 -0
- package/dist/primitives/grid.d.ts +3 -0
- package/dist/primitives/interval-band.d.ts +4 -0
- package/dist/primitives/line.d.ts +8 -0
- package/dist/primitives/plot-background.d.ts +10 -0
- package/dist/primitives/reference-line.d.ts +4 -0
- package/dist/primitives/runoff.d.ts +49 -0
- package/dist/runtime/chart-runtime.d.ts +95 -0
- package/dist/styles.css +2 -0
- package/dist/toolkit/chart-brush.d.ts +3 -0
- package/dist/toolkit/chart-overview.d.ts +3 -0
- package/dist/toolkit/chart-range-summary.d.ts +5 -0
- package/dist/toolkit/chart-readout.d.ts +3 -0
- package/dist/toolkit/chart-toolbar.d.ts +3 -0
- package/dist/toolkit/comparison-details.d.ts +7 -0
- package/dist/types.d.ts +555 -0
- package/dist/use-chart-width.d.ts +5 -0
- package/media/cards-dark.webp +0 -0
- package/media/cards-light.webp +0 -0
- package/media/hero-dark.webp +0 -0
- package/media/hero-light.webp +0 -0
- package/package.json +71 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ChartComparisonContext } from '../types';
|
|
2
|
+
export interface ComparisonDetailsProps {
|
|
3
|
+
comparison: ChartComparisonContext;
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
/** Optional content. Use in a tooltip, header or footer, or replace with your own JSX. */
|
|
7
|
+
export declare function ComparisonDetails({ comparison, className }: ComparisonDetailsProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,555 @@
|
|
|
1
|
+
import { CSSProperties, ReactElement, ReactNode } from 'react';
|
|
2
|
+
/** step-after holds the left value until the next x; step-before holds the right value. */
|
|
3
|
+
export type ChartCurve = 'linear' | 'monotone' | 'step-after' | 'step-before';
|
|
4
|
+
/** Restrained fills shared by marks and their inspection keys. */
|
|
5
|
+
export type ChartFillTreatment = 'solid' | 'fade' | 'hatch' | 'dots';
|
|
6
|
+
export type ChartObservationStatus = 'observed' | 'provisional' | 'forecast';
|
|
7
|
+
export type ChartMotion = 'auto' | 'none';
|
|
8
|
+
export type ChartStatus = 'loading' | 'ready' | 'error';
|
|
9
|
+
/** Standard CSS plus scoped Lilt tokens, usable on every chart root. */
|
|
10
|
+
export type ChartStyle = CSSProperties & {
|
|
11
|
+
[token: `--lilt-${string}`]: string | number | undefined;
|
|
12
|
+
};
|
|
13
|
+
export interface ChartLineStyle {
|
|
14
|
+
width?: number;
|
|
15
|
+
opacity?: number;
|
|
16
|
+
dasharray?: string;
|
|
17
|
+
cap?: 'butt' | 'round' | 'square';
|
|
18
|
+
join?: 'miter' | 'round' | 'bevel';
|
|
19
|
+
/** Radius of isolated observations and inspected line or area points. */
|
|
20
|
+
pointRadius?: number;
|
|
21
|
+
pointStroke?: string;
|
|
22
|
+
pointStrokeWidth?: number;
|
|
23
|
+
/** Show the point on this series during inspection. Defaults to true. */
|
|
24
|
+
showInspectionPoint?: boolean;
|
|
25
|
+
/** Label the latest finite endpoint when the plot has a wide right gutter. */
|
|
26
|
+
directLabel?: boolean;
|
|
27
|
+
/** Mark every observation with a small dot ringed in the surface color. */
|
|
28
|
+
points?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface ChartAreaStyle {
|
|
31
|
+
/** Fade a solid or patterned area toward its baseline without changing geometry. */
|
|
32
|
+
fade?: boolean;
|
|
33
|
+
/** Fill opacity at rest. Defaults to 0.62 for stacks and 1 for gradients. */
|
|
34
|
+
opacity?: number;
|
|
35
|
+
/** CSS color or paint value. Omit to use Lilt's gradient or the series color. */
|
|
36
|
+
fill?: string;
|
|
37
|
+
/** A chart-owned paint treatment; explicit fill takes precedence. */
|
|
38
|
+
treatment?: ChartFillTreatment;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* How a bar is drawn: `solid`, `segmented` into small cells, `needle` (a thin segmented line that
|
|
42
|
+
* expands on hover), `gradient` fading toward the baseline, or `outline`.
|
|
43
|
+
*/
|
|
44
|
+
export type ChartBarAppearance = 'solid' | 'segmented' | 'needle' | 'gradient' | 'outline';
|
|
45
|
+
export interface ChartBarStyle {
|
|
46
|
+
/** How each bar is drawn. Defaults to `solid`. */
|
|
47
|
+
appearance?: ChartBarAppearance;
|
|
48
|
+
/** Radius of the exposed value end in CSS pixels. Stacked bars default to 0. */
|
|
49
|
+
radius?: number;
|
|
50
|
+
/** Round both the top and bottom of each bar segment. */
|
|
51
|
+
roundBothEnds?: boolean;
|
|
52
|
+
stroke?: string;
|
|
53
|
+
strokeWidth?: number;
|
|
54
|
+
fillOpacity?: number;
|
|
55
|
+
/** Decorative paint clipped to the exact bar geometry. */
|
|
56
|
+
treatment?: Exclude<ChartFillTreatment, 'fade'>;
|
|
57
|
+
/**
|
|
58
|
+
* Quiet full-scale lane behind each observed bar. In a stack, the bottom series' track sits
|
|
59
|
+
* behind the whole column. It follows `roundBothEnds`.
|
|
60
|
+
*/
|
|
61
|
+
track?: {
|
|
62
|
+
fill?: string;
|
|
63
|
+
opacity?: number;
|
|
64
|
+
radius?: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export interface ChartBarLayout {
|
|
68
|
+
/** Desired maximum width of each bar in CSS pixels; clamped to its x slot. */
|
|
69
|
+
width?: number;
|
|
70
|
+
/** Space between bars within a grouped x slot, in CSS pixels. */
|
|
71
|
+
gap?: number;
|
|
72
|
+
/** Space between segments of a stack, in CSS pixels. Defaults to 0. */
|
|
73
|
+
segmentGap?: number;
|
|
74
|
+
}
|
|
75
|
+
export interface ChartSeries<T> {
|
|
76
|
+
id: string;
|
|
77
|
+
label: string;
|
|
78
|
+
unit?: string;
|
|
79
|
+
accessor: (row: T) => number | null;
|
|
80
|
+
/** Explicit source status. The last row is never inferred to be provisional. */
|
|
81
|
+
status?: (row: T) => ChartObservationStatus;
|
|
82
|
+
/** Supplied bounds in the same unit as accessor; Lilt does not infer confidence. */
|
|
83
|
+
interval?: {
|
|
84
|
+
lower: (row: T) => number | null;
|
|
85
|
+
upper: (row: T) => number | null;
|
|
86
|
+
meaning: string;
|
|
87
|
+
};
|
|
88
|
+
color?: string;
|
|
89
|
+
line?: ChartLineStyle;
|
|
90
|
+
area?: ChartAreaStyle;
|
|
91
|
+
bar?: ChartBarStyle;
|
|
92
|
+
formatValue?: (value: number) => string;
|
|
93
|
+
curve?: ChartCurve;
|
|
94
|
+
/**
|
|
95
|
+
* `secondary` fits this series to its own value scale, for a different unit such as a rate
|
|
96
|
+
* over revenue bars. The scale shares the primary gridlines; `YAxis scale="secondary"` labels
|
|
97
|
+
* it. Stacked series always share the primary scale.
|
|
98
|
+
*/
|
|
99
|
+
scale?: 'primary' | 'secondary';
|
|
100
|
+
}
|
|
101
|
+
export interface TimeXConfig<T> {
|
|
102
|
+
type: 'time';
|
|
103
|
+
accessor: (row: T) => Date | number;
|
|
104
|
+
format?: (value: number) => string;
|
|
105
|
+
}
|
|
106
|
+
export interface NumericXConfig<T> {
|
|
107
|
+
type: 'number';
|
|
108
|
+
accessor: (row: T) => number;
|
|
109
|
+
format?: (value: number) => string;
|
|
110
|
+
}
|
|
111
|
+
export interface CategoryXConfig<T> {
|
|
112
|
+
type: 'category';
|
|
113
|
+
/** Stable, unique category identity. Input order determines its position. */
|
|
114
|
+
accessor: (row: T) => string;
|
|
115
|
+
format?: (id: string) => string;
|
|
116
|
+
}
|
|
117
|
+
export type ChartXConfig<T> = TimeXConfig<T> | NumericXConfig<T> | CategoryXConfig<T>;
|
|
118
|
+
export interface ChartYConfig {
|
|
119
|
+
includeZero?: boolean;
|
|
120
|
+
domain?: readonly [number, number];
|
|
121
|
+
/** Values the fitted domain must contain, such as a target line. Ignored with `domain`. */
|
|
122
|
+
include?: readonly number[];
|
|
123
|
+
format?: (value: number) => string;
|
|
124
|
+
/** Labels of the secondary scale. Defaults to the first secondary series' `formatValue`. */
|
|
125
|
+
secondaryFormat?: (value: number) => string;
|
|
126
|
+
ticks?: number;
|
|
127
|
+
}
|
|
128
|
+
export interface ChartMargins {
|
|
129
|
+
top: number;
|
|
130
|
+
right: number;
|
|
131
|
+
bottom: number;
|
|
132
|
+
left: number;
|
|
133
|
+
}
|
|
134
|
+
interface ChartCommonProps<T> {
|
|
135
|
+
data: readonly T[];
|
|
136
|
+
/** Suppress inspection and selection feedback while retaining external selection ownership. */
|
|
137
|
+
interactive?: boolean;
|
|
138
|
+
y?: ChartYConfig;
|
|
139
|
+
series: readonly ChartSeries<T>[];
|
|
140
|
+
className?: string;
|
|
141
|
+
style?: CSSProperties | ChartStyle;
|
|
142
|
+
'aria-label': string;
|
|
143
|
+
children?: ReactNode;
|
|
144
|
+
status?: ChartStatus;
|
|
145
|
+
error?: string;
|
|
146
|
+
renderRetry?: () => ReactNode;
|
|
147
|
+
motion?: ChartMotion;
|
|
148
|
+
/** Play the first-data entrance (also after resetKey). Defaults to true; updates remain animated. */
|
|
149
|
+
animateIn?: boolean;
|
|
150
|
+
resetKey?: string | number;
|
|
151
|
+
onSelectionChange?: (selection: ChartSelection<T> | null) => void;
|
|
152
|
+
/** Controlled series visibility. Omit to show every descriptor. */
|
|
153
|
+
visibleSeries?: readonly string[];
|
|
154
|
+
onVisibleSeriesChange?: (series: readonly string[]) => void;
|
|
155
|
+
}
|
|
156
|
+
export type ChartProps<T> = ChartCommonProps<T> & ({
|
|
157
|
+
x: TimeXConfig<T> | NumericXConfig<T>;
|
|
158
|
+
/** Share inspection and range state across charts. */
|
|
159
|
+
controller?: ChartController;
|
|
160
|
+
linkedSelection?: 'exact' | {
|
|
161
|
+
nearestWithin: number;
|
|
162
|
+
};
|
|
163
|
+
compare?: boolean | ChartCompareConfig;
|
|
164
|
+
focus?: boolean | ChartFocusConfig;
|
|
165
|
+
live?: boolean | ChartLiveConfig;
|
|
166
|
+
brush?: boolean;
|
|
167
|
+
selectedCategoryId?: never;
|
|
168
|
+
onSelectedCategoryIdChange?: never;
|
|
169
|
+
} | {
|
|
170
|
+
x: CategoryXConfig<T>;
|
|
171
|
+
/** Controlled pinned category; hover and keyboard focus stay local. */
|
|
172
|
+
selectedCategoryId?: string | null;
|
|
173
|
+
onSelectedCategoryIdChange?: (id: string | null) => void;
|
|
174
|
+
controller?: never;
|
|
175
|
+
linkedSelection?: never;
|
|
176
|
+
compare?: never;
|
|
177
|
+
focus?: never;
|
|
178
|
+
live?: never;
|
|
179
|
+
brush?: never;
|
|
180
|
+
});
|
|
181
|
+
/**
|
|
182
|
+
* Axis presets.
|
|
183
|
+
* - `classic`: y labels in a left gutter, x labels under the plot.
|
|
184
|
+
* - `inline`: y labels sit on their grid lines inside the plot, so the plot runs full width.
|
|
185
|
+
* - `ruler`: inline y labels plus a crisp tick under every observation; the active tick grows.
|
|
186
|
+
* - `minimal`: no y labels or grid; the x axis labels only its ends.
|
|
187
|
+
* - `dots`: minimal plus a dot under every observation that swells under the pointer.
|
|
188
|
+
*/
|
|
189
|
+
export type ChartAxisStyle = 'classic' | 'inline' | 'ruler' | 'minimal' | 'dots';
|
|
190
|
+
/**
|
|
191
|
+
* How hover pills and tooltips look: quiet surface glass `soft` (default), inverted `solid`, or
|
|
192
|
+
* `accent`, which takes the color of the series under the pointer.
|
|
193
|
+
*/
|
|
194
|
+
export type ChartHoverStyle = 'soft' | 'solid' | 'accent';
|
|
195
|
+
/**
|
|
196
|
+
* What a card shows for the hovered point. `pills` (default) puts the date and value on the
|
|
197
|
+
* axes; `tooltip` gathers every series in one floating panel; `headline` keeps the plot clear
|
|
198
|
+
* and reads out through the headline and tiles alone.
|
|
199
|
+
*/
|
|
200
|
+
export type ChartHoverReadout = 'pills' | 'tooltip' | 'headline';
|
|
201
|
+
/** The series marker on each tooltip row: a rounded `square` (default), a `dot`, or a `line`. */
|
|
202
|
+
export type ChartTooltipIndicator = 'square' | 'dot' | 'line';
|
|
203
|
+
/**
|
|
204
|
+
* Series color sets, each validated for color-vision deficiency in light and dark mode. `iris`
|
|
205
|
+
* is the default.
|
|
206
|
+
*/
|
|
207
|
+
export type ChartPalette = 'iris' | 'cobalt' | 'emerald';
|
|
208
|
+
/** Texture behind the plot marks, faded toward the plot edges. */
|
|
209
|
+
export type ChartBackground = 'dots' | 'grid' | 'lines' | 'none';
|
|
210
|
+
/** Card treatments: raised `elevated` (default), border-only `outline`, or `ghost` for use inside your own card. */
|
|
211
|
+
export type ChartSurface = 'elevated' | 'outline' | 'ghost';
|
|
212
|
+
interface ChartPlotCommonProps {
|
|
213
|
+
children?: ReactNode;
|
|
214
|
+
/** Axis presentation. Defaults to `minimal`. */
|
|
215
|
+
axis?: ChartAxisStyle;
|
|
216
|
+
/** Hover pill treatment, or `false` to inspect without pills. Defaults to `soft`. */
|
|
217
|
+
pill?: ChartHoverStyle | false;
|
|
218
|
+
/**
|
|
219
|
+
* Which series the y pill follows. `nearest` (default) follows the line closest to the pointer;
|
|
220
|
+
* a series ID locks it; `total` follows the top of a stack.
|
|
221
|
+
*/
|
|
222
|
+
pillSeries?: 'nearest' | 'total' | (string & {});
|
|
223
|
+
/** In stacks, show the series' own value (`series`, default) or the stacked height at its edge (`stack`). */
|
|
224
|
+
pillValue?: 'series' | 'stack';
|
|
225
|
+
/**
|
|
226
|
+
* Where the value pill sits: `axis` on the y axis, `mark` centered above the hovered bar or
|
|
227
|
+
* point. `auto` (default) uses `mark` when the axis shows no y labels.
|
|
228
|
+
*/
|
|
229
|
+
pillPosition?: 'auto' | 'axis' | 'mark';
|
|
230
|
+
/** Texture behind the marks. Defaults to `none` here; cards default to `dots`. */
|
|
231
|
+
background?: ChartBackground;
|
|
232
|
+
/** Brighten the background around the inspected point. Defaults to true. */
|
|
233
|
+
spotlight?: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Padding in pixels between the plot's left and right edges and its axis labels, ruler ends,
|
|
236
|
+
* and hover pills. Observations move inward by the same amount so labels center on them.
|
|
237
|
+
* Defaults to 0.
|
|
238
|
+
*/
|
|
239
|
+
axisInset?: number;
|
|
240
|
+
/**
|
|
241
|
+
* With an `axisInset`, continue lines and areas from the first and last observations to the
|
|
242
|
+
* plot edges, fading out. Decorative only: it carries no values and is not inspectable.
|
|
243
|
+
*/
|
|
244
|
+
runoff?: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* How far the first and last x labels may extend past the plot edges so they stay centered on
|
|
247
|
+
* their observations, as in a chart surrounded by padding. Defaults to 0.
|
|
248
|
+
*/
|
|
249
|
+
labelOverhang?: number;
|
|
250
|
+
/** Use 'fill' to size the plot from its flex container; otherwise use a pixel height. */
|
|
251
|
+
height?: number | 'fill';
|
|
252
|
+
compactHeight?: number;
|
|
253
|
+
margins?: Partial<ChartMargins>;
|
|
254
|
+
/** Axis-free inspection presentation for compact charts. */
|
|
255
|
+
compact?: boolean;
|
|
256
|
+
className?: string;
|
|
257
|
+
style?: CSSProperties | ChartStyle;
|
|
258
|
+
/** Inspection panel settings. Use this when plot children are produced by a component. */
|
|
259
|
+
tooltip?: TooltipProps | ReactElement | false;
|
|
260
|
+
/** Series used for the inspection-axis badge. */
|
|
261
|
+
inspectionSeries?: string;
|
|
262
|
+
}
|
|
263
|
+
/** Bars for a plot. Series left out draw as lines over the bars, e.g. a target or a rate. */
|
|
264
|
+
export interface ChartBars<Id extends string = string> extends ChartBarLayout {
|
|
265
|
+
/**
|
|
266
|
+
* Series drawn as bars. Defaults to every series, or to the stacked series when the plot also
|
|
267
|
+
* stacks; stacked bars always draw exactly the stack.
|
|
268
|
+
*/
|
|
269
|
+
series?: readonly Id[];
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* How stacked series combine. `sum` adds values, positives above zero and negatives below;
|
|
273
|
+
* `percent` shows each series' share of its period and requires non-negative values.
|
|
274
|
+
*/
|
|
275
|
+
export type ChartStackMode = 'sum' | 'percent';
|
|
276
|
+
export interface ChartStack<Id extends string = string> {
|
|
277
|
+
/**
|
|
278
|
+
* Series that stack, bottom to top in chart series order. Defaults to every series. The rest
|
|
279
|
+
* draw unstacked over the stack on the same scale, or on their own with `scale: 'secondary'`.
|
|
280
|
+
*/
|
|
281
|
+
series?: readonly Id[];
|
|
282
|
+
/** Defaults to `sum`. */
|
|
283
|
+
mode?: ChartStackMode;
|
|
284
|
+
}
|
|
285
|
+
export interface ChartPlotProps extends ChartPlotCommonProps {
|
|
286
|
+
/** Draw series as bars: `true` for every series, or choose series and spacing. */
|
|
287
|
+
bars?: true | ChartBars;
|
|
288
|
+
/** Stack series: `true` or `'sum'` adds every series, `'percent'` shows shares. */
|
|
289
|
+
stack?: true | ChartStackMode | ChartStack;
|
|
290
|
+
}
|
|
291
|
+
export interface BarProps {
|
|
292
|
+
series: string;
|
|
293
|
+
className?: string;
|
|
294
|
+
}
|
|
295
|
+
export type RankingOrder = 'descending' | 'ascending' | 'input';
|
|
296
|
+
export interface CategorySelection<T> {
|
|
297
|
+
id: string;
|
|
298
|
+
row: T;
|
|
299
|
+
value: number | null;
|
|
300
|
+
pinned: boolean;
|
|
301
|
+
}
|
|
302
|
+
export interface ChartToolbarProps {
|
|
303
|
+
actions?: ReactNode;
|
|
304
|
+
className?: string;
|
|
305
|
+
}
|
|
306
|
+
export interface ChartReadoutProps {
|
|
307
|
+
/** Optional normal-flow text summary; keyboard input remains in the plot. */
|
|
308
|
+
className?: string;
|
|
309
|
+
}
|
|
310
|
+
export interface ChartBrushProps {
|
|
311
|
+
className?: string;
|
|
312
|
+
}
|
|
313
|
+
export interface ChartOverviewProps {
|
|
314
|
+
className?: string;
|
|
315
|
+
}
|
|
316
|
+
export interface LineProps {
|
|
317
|
+
series: string;
|
|
318
|
+
className?: string;
|
|
319
|
+
}
|
|
320
|
+
export interface AreaProps {
|
|
321
|
+
series: string;
|
|
322
|
+
className?: string;
|
|
323
|
+
}
|
|
324
|
+
export interface IntervalBandProps {
|
|
325
|
+
series: string;
|
|
326
|
+
className?: string;
|
|
327
|
+
}
|
|
328
|
+
export interface PrimitiveProps {
|
|
329
|
+
className?: string;
|
|
330
|
+
}
|
|
331
|
+
export interface XAxisProps extends PrimitiveProps {
|
|
332
|
+
/** Insets only the first and last tick labels; the plotted data stays edge to edge. */
|
|
333
|
+
edgeInset?: number;
|
|
334
|
+
/**
|
|
335
|
+
* `ends` labels only the first and last observation; `fit` labels as many as fit. Minimal and
|
|
336
|
+
* dots axes default to `ends`, which suits lines and areas; bars read better with `fit`.
|
|
337
|
+
*/
|
|
338
|
+
labels?: 'ends' | 'fit';
|
|
339
|
+
}
|
|
340
|
+
export interface GridProps extends PrimitiveProps {
|
|
341
|
+
pattern?: 'lines' | 'dots';
|
|
342
|
+
color?: string;
|
|
343
|
+
opacity?: number;
|
|
344
|
+
lineWidth?: number;
|
|
345
|
+
dotSpacing?: number;
|
|
346
|
+
dotRadius?: number;
|
|
347
|
+
}
|
|
348
|
+
export interface YAxisProps extends PrimitiveProps {
|
|
349
|
+
showTicks?: boolean;
|
|
350
|
+
/** `secondary` labels series drawn with `scale: 'secondary'` on the right edge. */
|
|
351
|
+
scale?: 'primary' | 'secondary';
|
|
352
|
+
}
|
|
353
|
+
export interface TooltipProps<Row = unknown, SeriesId extends string = string> extends PrimitiveProps {
|
|
354
|
+
/** Optional accessible label for the inspection panel. */
|
|
355
|
+
'aria-label'?: string;
|
|
356
|
+
/** Keep plot inspection without a floating panel. Add ChartReadout separately if wanted. */
|
|
357
|
+
floating?: boolean;
|
|
358
|
+
/** Panel treatment: `soft` (default), `solid`, or `accent`. */
|
|
359
|
+
variant?: ChartHoverStyle;
|
|
360
|
+
/** Series marker on each row: `square` (default), `dot`, or `line`. */
|
|
361
|
+
indicator?: ChartTooltipIndicator;
|
|
362
|
+
/**
|
|
363
|
+
* Below 420px, and while another chart drives inspection, show a readout under the plot
|
|
364
|
+
* instead of the floating panel. Defaults to true.
|
|
365
|
+
*/
|
|
366
|
+
adaptive?: boolean;
|
|
367
|
+
/** Icon in the pinned inspection banner. Defaults to Lilt's native pin. */
|
|
368
|
+
pinIcon?: ReactNode;
|
|
369
|
+
/** Replace the default values body with accepted-value JSX; title, placement and pin actions remain. */
|
|
370
|
+
renderContent?: (context: ChartTooltipContext<Row, SeriesId>) => ReactNode;
|
|
371
|
+
/** Opt in to comparison content in this tooltip. Omit to render it elsewhere. */
|
|
372
|
+
renderComparison?: (context: ChartComparisonContext<SeriesId, Row>) => ReactNode;
|
|
373
|
+
}
|
|
374
|
+
export interface ChartTooltipContext<Row = unknown, SeriesId extends string = string> {
|
|
375
|
+
/** The series the pointer, keyboard, or legend currently points at, when there is one. */
|
|
376
|
+
activeSeriesId?: SeriesId | null;
|
|
377
|
+
row: Row;
|
|
378
|
+
sourceIndex: number;
|
|
379
|
+
x: number;
|
|
380
|
+
formattedX: string;
|
|
381
|
+
pinned: boolean;
|
|
382
|
+
series: readonly {
|
|
383
|
+
id: SeriesId;
|
|
384
|
+
label: string;
|
|
385
|
+
value: number | null;
|
|
386
|
+
formattedValue: string;
|
|
387
|
+
status: ChartObservationStatus;
|
|
388
|
+
interval: {
|
|
389
|
+
lower: number;
|
|
390
|
+
upper: number;
|
|
391
|
+
meaning: string;
|
|
392
|
+
} | null;
|
|
393
|
+
}[];
|
|
394
|
+
}
|
|
395
|
+
export interface ChartLegendValue {
|
|
396
|
+
id: string;
|
|
397
|
+
label: string;
|
|
398
|
+
value: number | null;
|
|
399
|
+
formattedValue: string;
|
|
400
|
+
status: ChartObservationStatus;
|
|
401
|
+
}
|
|
402
|
+
export interface LegendProps extends PrimitiveProps {
|
|
403
|
+
/** Value cards are the default; inline uses compact dot-and-label items. */
|
|
404
|
+
variant?: 'cards' | 'inline';
|
|
405
|
+
/** Series show one entry per descriptor; observations show one entry per x bucket. */
|
|
406
|
+
by?: 'series' | 'observation';
|
|
407
|
+
/** Value source for observation entries. Defaults to the first visible series. */
|
|
408
|
+
series?: string;
|
|
409
|
+
style?: CSSProperties;
|
|
410
|
+
/** Enable series toggles and hover/focus emphasis. Defaults to true. */
|
|
411
|
+
interactive?: boolean;
|
|
412
|
+
/** Show the isolate action; activating an isolated series restores the prior selection. Defaults to true. */
|
|
413
|
+
allowIsolate?: boolean;
|
|
414
|
+
/** Override the accepted hover/pin value slot. */
|
|
415
|
+
renderValue?: (entry: ChartLegendValue) => ReactNode;
|
|
416
|
+
renderLabel?: (entry: ChartLegendValue) => ReactNode;
|
|
417
|
+
renderSwatch?: (entry: ChartLegendValue & {
|
|
418
|
+
color: string;
|
|
419
|
+
}) => ReactNode;
|
|
420
|
+
/** Consumer-owned comparison presentation for each series card. */
|
|
421
|
+
renderDifference?: (difference: ChartComparisonSeries, entry: ChartLegendValue) => ReactNode;
|
|
422
|
+
/** Replace one item's content; the outer item keeps linked hover/focus behaviour. */
|
|
423
|
+
renderItem?: (entry: ChartLegendValue & {
|
|
424
|
+
color: string;
|
|
425
|
+
}, actions: {
|
|
426
|
+
toggle: () => void;
|
|
427
|
+
focus: () => void;
|
|
428
|
+
isolate: () => void;
|
|
429
|
+
comparison: ChartComparisonSeries | null;
|
|
430
|
+
}) => ReactNode;
|
|
431
|
+
}
|
|
432
|
+
export type ChartPercentagePolicy = 'positive-baseline' | 'signed' | 'absolute-baseline' | 'none';
|
|
433
|
+
export interface ChartCompareConfig {
|
|
434
|
+
/** Lead series for the focus overview. Results always include every visible series. */
|
|
435
|
+
series?: string;
|
|
436
|
+
percentage?: ChartPercentagePolicy;
|
|
437
|
+
/** Accepted values for all visible series, including range previews. No UI is inserted. */
|
|
438
|
+
onChange?: (comparison: ChartComparisonResult | null) => void;
|
|
439
|
+
}
|
|
440
|
+
export interface ChartFocusConfig {
|
|
441
|
+
overview?: boolean;
|
|
442
|
+
onChange?: (range: ChartRange | null) => void;
|
|
443
|
+
}
|
|
444
|
+
export interface ChartLiveConfig {
|
|
445
|
+
label?: string;
|
|
446
|
+
returnLabel?: string;
|
|
447
|
+
onFollowingChange?: (following: boolean) => void;
|
|
448
|
+
}
|
|
449
|
+
export interface ChartRange {
|
|
450
|
+
readonly startX: number;
|
|
451
|
+
readonly endX: number;
|
|
452
|
+
}
|
|
453
|
+
export interface ChartComparison extends ChartRange {
|
|
454
|
+
series: string;
|
|
455
|
+
startValue: number | null;
|
|
456
|
+
endValue: number | null;
|
|
457
|
+
absoluteChange: number | null;
|
|
458
|
+
percentageChange: number | null;
|
|
459
|
+
elapsed: number;
|
|
460
|
+
unavailableReason?: string;
|
|
461
|
+
}
|
|
462
|
+
export interface ChartComparisonSeries<Id extends string = string> extends Omit<ChartComparison, 'series'> {
|
|
463
|
+
id: Id;
|
|
464
|
+
label: string;
|
|
465
|
+
color: string;
|
|
466
|
+
dasharray?: string;
|
|
467
|
+
formattedStartValue: string;
|
|
468
|
+
formattedEndValue: string;
|
|
469
|
+
formattedChange: string;
|
|
470
|
+
formattedPercentage: string | null;
|
|
471
|
+
}
|
|
472
|
+
/** Presentation-independent endpoint changes, never interval sums or interpolated values. */
|
|
473
|
+
export interface ChartComparisonResult<Id extends string = string, Row = unknown> extends ChartRange {
|
|
474
|
+
kind: 'range';
|
|
475
|
+
startRow: Row | null;
|
|
476
|
+
endRow: Row | null;
|
|
477
|
+
startSourceIndex: number | null;
|
|
478
|
+
endSourceIndex: number | null;
|
|
479
|
+
percentagePolicy: ChartPercentagePolicy;
|
|
480
|
+
formattedStartX: string;
|
|
481
|
+
formattedEndX: string;
|
|
482
|
+
elapsed: number;
|
|
483
|
+
phase: 'preview' | 'complete';
|
|
484
|
+
focused: boolean;
|
|
485
|
+
series: readonly ChartComparisonSeries<Id>[];
|
|
486
|
+
}
|
|
487
|
+
/** Available through useChartComparison and an explicitly supplied tooltip renderer. */
|
|
488
|
+
export interface ChartComparisonContext<Id extends string = string, Row = unknown> extends ChartComparisonResult<Id, Row> {
|
|
489
|
+
motion: ChartMotion;
|
|
490
|
+
clear: () => void;
|
|
491
|
+
focus?: () => void;
|
|
492
|
+
fullRange?: () => void;
|
|
493
|
+
}
|
|
494
|
+
export interface ChartControllerInspection {
|
|
495
|
+
readonly x: number;
|
|
496
|
+
readonly pinned: boolean;
|
|
497
|
+
readonly ownerId: string;
|
|
498
|
+
}
|
|
499
|
+
export interface ChartControllerSnapshot {
|
|
500
|
+
readonly inspection: ChartControllerInspection | null;
|
|
501
|
+
readonly comparison: (ChartRange & {
|
|
502
|
+
readonly series?: string;
|
|
503
|
+
}) | null;
|
|
504
|
+
readonly focus: ChartRange | null;
|
|
505
|
+
}
|
|
506
|
+
export interface ChartController {
|
|
507
|
+
getSnapshot: () => ChartControllerSnapshot;
|
|
508
|
+
subscribe: (listener: () => void) => () => void;
|
|
509
|
+
inspect: (inspection: ChartControllerInspection) => void;
|
|
510
|
+
clearInspection: (ownerId?: string) => void;
|
|
511
|
+
/** Detach an unmounted input owner; retained pins and ranges survive expansion. */
|
|
512
|
+
releaseOwner: (ownerId: string) => void;
|
|
513
|
+
setComparison: (comparison: (ChartRange & {
|
|
514
|
+
series?: string;
|
|
515
|
+
}) | null) => void;
|
|
516
|
+
setFocus: (range: ChartRange | null) => void;
|
|
517
|
+
}
|
|
518
|
+
export interface ChartAnnotation {
|
|
519
|
+
id: string;
|
|
520
|
+
x: number | Date;
|
|
521
|
+
label: string;
|
|
522
|
+
description?: string;
|
|
523
|
+
color?: string;
|
|
524
|
+
}
|
|
525
|
+
export interface AnnotationsProps extends PrimitiveProps {
|
|
526
|
+
items: readonly ChartAnnotation[];
|
|
527
|
+
onSelectionChange?: (annotation: ChartAnnotation | null) => void;
|
|
528
|
+
}
|
|
529
|
+
export interface ReferenceBandProps extends PrimitiveProps {
|
|
530
|
+
/** Pass `-Infinity` or `Infinity` for an open end that runs to the plot's edge. */
|
|
531
|
+
from: number | Date;
|
|
532
|
+
to: number | Date;
|
|
533
|
+
label: string;
|
|
534
|
+
color?: string;
|
|
535
|
+
}
|
|
536
|
+
export interface ReferenceLineProps extends PrimitiveProps {
|
|
537
|
+
/** The y value, in the primary scale's unit. */
|
|
538
|
+
value: number;
|
|
539
|
+
/** Text at the line's right end, e.g. "Target $4,000". */
|
|
540
|
+
label?: string;
|
|
541
|
+
color?: string;
|
|
542
|
+
}
|
|
543
|
+
export interface ChangeComparisonProps<T> extends PrimitiveProps {
|
|
544
|
+
data: readonly T[];
|
|
545
|
+
label: string;
|
|
546
|
+
series?: string;
|
|
547
|
+
}
|
|
548
|
+
export interface ChartSelection<T> {
|
|
549
|
+
row: T;
|
|
550
|
+
sourceIndex: number;
|
|
551
|
+
x: number;
|
|
552
|
+
categoryId?: string;
|
|
553
|
+
pinned: boolean;
|
|
554
|
+
}
|
|
555
|
+
export {};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lilt-ui/charts",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Beautiful, key-typed React chart cards with linked hover, targets, forecasts, and calm motion.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"charts",
|
|
8
|
+
"chart",
|
|
9
|
+
"dashboard",
|
|
10
|
+
"data-visualization",
|
|
11
|
+
"area-chart",
|
|
12
|
+
"bar-chart",
|
|
13
|
+
"line-chart",
|
|
14
|
+
"sparkline",
|
|
15
|
+
"typescript"
|
|
16
|
+
],
|
|
17
|
+
"author": "Lilt UI",
|
|
18
|
+
"homepage": "https://liltui.vercel.app",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"type": "module",
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"module": "./dist/index.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./data": {
|
|
31
|
+
"types": "./dist/data.d.ts",
|
|
32
|
+
"import": "./dist/data.js",
|
|
33
|
+
"default": "./dist/data.js"
|
|
34
|
+
},
|
|
35
|
+
"./styles.css": "./dist/styles.css",
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"media",
|
|
41
|
+
"README.md",
|
|
42
|
+
"LICENSE",
|
|
43
|
+
"THIRD_PARTY_NOTICES.md"
|
|
44
|
+
],
|
|
45
|
+
"sideEffects": [
|
|
46
|
+
"./dist/styles.css"
|
|
47
|
+
],
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "vite build",
|
|
50
|
+
"prepublishOnly": "pnpm build",
|
|
51
|
+
"typecheck": "tsc --noEmit && pnpm build && pnpm run typecheck:consumer",
|
|
52
|
+
"typecheck:consumer": "tsc --noEmit --strict --target ES2022 --module ESNext --moduleResolution Bundler --skipLibCheck consumer/typecheck.ts",
|
|
53
|
+
"lint": "eslint src",
|
|
54
|
+
"test": "pnpm build && vitest run",
|
|
55
|
+
"format:check": "prettier --check src vite.config.ts tsconfig.json"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@number-flow/react": "^0.6.2",
|
|
59
|
+
"d3-array": "^3.2.4",
|
|
60
|
+
"d3-scale": "^4.0.2",
|
|
61
|
+
"d3-shape": "^3.2.0",
|
|
62
|
+
"motion": "^13.4.0"
|
|
63
|
+
},
|
|
64
|
+
"publishConfig": {
|
|
65
|
+
"access": "public"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"react": "^19.0.0",
|
|
69
|
+
"react-dom": "^19.0.0"
|
|
70
|
+
}
|
|
71
|
+
}
|