@lilt-ui/charts 0.1.0 → 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.
- package/CHANGELOG.md +69 -0
- package/README.md +120 -0
- package/dist/analysis-BJRmXHOB.js +62 -0
- package/dist/cards/area-chart-card.d.ts +10 -1
- package/dist/cards/box-plot-card.d.ts +30 -0
- package/dist/cards/cartesian-card.d.ts +86 -6
- package/dist/cards/chart-card.d.ts +12 -1
- package/dist/cards/line-chart-card.d.ts +10 -1
- package/dist/cards/range-chart-card.d.ts +28 -0
- package/dist/cartesian-card-Dcd0ZnQL.js +7004 -0
- package/dist/chart-context.d.ts +18 -0
- package/dist/chart-data-CCwLQeXa.js +44 -0
- package/dist/chart.d.ts +3 -1
- package/dist/data.js +3 -2
- package/dist/engine/box.d.ts +18 -0
- package/dist/engine/domains.d.ts +2 -0
- package/dist/engine/geometry.d.ts +2 -1
- package/dist/engine/normalize.d.ts +2 -4
- package/dist/engine/ranges.d.ts +59 -0
- package/dist/finance/candle-geometry.d.ts +55 -0
- package/dist/finance/candles.d.ts +18 -0
- package/dist/finance/cards/candlestick-chart-card.d.ts +41 -0
- package/dist/finance/cards/depth-chart-card.d.ts +32 -0
- package/dist/finance/cards/indicator-chart-card.d.ts +52 -0
- package/dist/finance/cards/pane.d.ts +24 -0
- package/dist/finance/cards/portfolio-chart-card.d.ts +22 -0
- package/dist/finance/cards/price-chart-card.d.ts +27 -0
- package/dist/finance/index.d.ts +17 -0
- package/dist/finance/indicators.d.ts +65 -0
- package/dist/finance/order-book.d.ts +26 -0
- package/dist/finance.d.ts +2 -0
- package/dist/finance.js +1158 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.js +2239 -8793
- package/dist/interaction/axis-cursor.d.ts +12 -2
- package/dist/interaction/chart-sync.d.ts +11 -1
- package/dist/interaction/field-values.d.ts +12 -0
- package/dist/interaction/inspection-layer.d.ts +10 -1
- package/dist/interaction/pin-glyphs.d.ts +8 -0
- package/dist/interaction/pin-marker.d.ts +9 -1
- package/dist/marks/contract.d.ts +49 -0
- package/dist/marks/use-range-mark.d.ts +19 -0
- package/dist/model/cartesian-model.d.ts +3 -3
- package/dist/primitives/annotations.d.ts +1 -1
- package/dist/primitives/axis-segments.d.ts +23 -0
- package/dist/primitives/box-plot.d.ts +4 -0
- package/dist/primitives/error-bar.d.ts +4 -0
- package/dist/primitives/interval-band.d.ts +2 -2
- package/dist/primitives/range-bar.d.ts +4 -0
- package/dist/report-context-Cz0AYdV2.js +895 -0
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +114 -16
- package/dist/watch/board/board-state.d.ts +74 -0
- package/dist/watch/board/board-toast.d.ts +19 -0
- package/dist/watch/board/chart-board.d.ts +97 -0
- package/dist/watch/board/report-context.d.ts +3 -0
- package/dist/watch/engine/describe.d.ts +9 -0
- package/dist/watch/engine/explain.d.ts +48 -0
- package/dist/watch/engine/normal.d.ts +114 -0
- package/dist/watch/engine/robust.d.ts +7 -0
- package/dist/watch/engine/rules.d.ts +22 -0
- package/dist/watch/engine/status.d.ts +39 -0
- package/dist/watch/index.d.ts +14 -0
- package/dist/watch/normal-layer.d.ts +18 -0
- package/dist/watch.d.ts +2 -0
- package/dist/watch.js +628 -0
- package/package.json +16 -2
- package/dist/analysis-BLLWEKBw.js +0 -105
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MotionValue } from 'motion/react';
|
|
2
|
-
import { ChartAxisStyle, ChartHoverStyle } from '../types';
|
|
2
|
+
import { ChartAxis, ChartAxisStyle, ChartHoverStyle } from '../types';
|
|
3
3
|
/** Visual center of x tick labels below the plot; pills center on the same line. */
|
|
4
4
|
export declare const X_LABEL_CENTER = 22;
|
|
5
5
|
/** The inspection pill positions, shared so axis labels can react to the approaching pill. */
|
|
@@ -11,7 +11,8 @@ export interface AxisCursor {
|
|
|
11
11
|
y: MotionValue<number>;
|
|
12
12
|
/** 1 while this chart owns an inspection, else 0. */
|
|
13
13
|
active: MotionValue<number>;
|
|
14
|
-
|
|
14
|
+
/** The preset each axis uses. */
|
|
15
|
+
axis: ResolvedAxis;
|
|
15
16
|
pill: ChartHoverStyle;
|
|
16
17
|
/** Padding between the plot edges and axis labels or pills, for plots that run edge to edge. */
|
|
17
18
|
inset: number;
|
|
@@ -26,5 +27,14 @@ export declare const AxisCursorContext: import('react').Context<AxisCursor>;
|
|
|
26
27
|
export declare function useAxisCursor(): AxisCursor;
|
|
27
28
|
/** 1 when far from the pill, easing to 0 when the pill is on top of the label. */
|
|
28
29
|
export declare function proximityOpacity(distance: number, reach: number, active: number): number;
|
|
30
|
+
/** The preset each axis uses, and a segmented axis's color scale. */
|
|
31
|
+
export interface ResolvedAxis {
|
|
32
|
+
x: ChartAxisStyle;
|
|
33
|
+
y: ChartAxisStyle;
|
|
34
|
+
xGradient?: boolean | readonly string[];
|
|
35
|
+
yGradient?: boolean | readonly string[];
|
|
36
|
+
}
|
|
37
|
+
/** Split an `axis` prop into one preset per axis. An axis left out is `minimal`. */
|
|
38
|
+
export declare function resolveAxis(axis: ChartAxis | undefined): ResolvedAxis;
|
|
29
39
|
/** Pills sit on the y axis when it has labels, and above the hovered mark when it does not. */
|
|
30
40
|
export declare function resolvePillPosition(position: 'auto' | 'axis' | 'mark', style: ChartAxisStyle): 'axis' | 'mark';
|
|
@@ -13,6 +13,8 @@ interface SyncState {
|
|
|
13
13
|
readonly pinned: boolean;
|
|
14
14
|
/** The card whose pointer or keyboard set this position. */
|
|
15
15
|
readonly source: string;
|
|
16
|
+
/** That card's name, so linked cards can say where a pin came from. */
|
|
17
|
+
readonly label?: string;
|
|
16
18
|
}
|
|
17
19
|
/** Inspections this bridge writes into a card's controller carry this owner. */
|
|
18
20
|
export declare const SYNC_OWNER = "sync";
|
|
@@ -27,9 +29,17 @@ export declare function useChartSync(name: string | undefined): ChartSyncPositio
|
|
|
27
29
|
* card has no row there.
|
|
28
30
|
*/
|
|
29
31
|
export declare function syncTarget(state: Pick<SyncState, 'key' | 'kind'>, kind: XKind, labels: readonly string[], positions: readonly number[]): number | null;
|
|
32
|
+
export interface CardSyncOptions {
|
|
33
|
+
/** The card's name, shown on linked cards' pins: "Pinned from Revenue". */
|
|
34
|
+
label?: string;
|
|
35
|
+
/** Releases the card's own pin when a linked card releases the group's. */
|
|
36
|
+
release?: () => void;
|
|
37
|
+
}
|
|
30
38
|
/**
|
|
31
39
|
* Link a card's hover and pin to every other card in the same named group. The card's own
|
|
32
40
|
* controller stays the source of truth; this bridge only copies positions between controllers.
|
|
41
|
+
* A pin is shared unless it is local, as Alt-click makes it; a shared pin can be released from
|
|
42
|
+
* any card in the group, and local pins stay put.
|
|
33
43
|
*/
|
|
34
|
-
export declare function useCardSync<Row>(name: string | undefined, controller: ChartController, data: readonly Row[], x: string, resolved: ResolvedX<Row
|
|
44
|
+
export declare function useCardSync<Row>(name: string | undefined, controller: ChartController, data: readonly Row[], x: string, resolved: ResolvedX<Row>, { label, release }?: CardSyncOptions): void;
|
|
35
45
|
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { ChartSeries, ChartTooltipField } from '../types';
|
|
3
|
+
/** A series' companion values for one row, in descriptor order. */
|
|
4
|
+
export declare function fieldEntries<T>(descriptor: ChartSeries<T>, values: Readonly<Record<string, number | null>> | undefined, format: (value: number) => string): ChartTooltipField[];
|
|
5
|
+
export declare function FieldList({ fields }: {
|
|
6
|
+
fields: readonly ChartTooltipField[];
|
|
7
|
+
}): ReactElement;
|
|
8
|
+
export declare function FieldValues<T>({ descriptor, values, format, }: {
|
|
9
|
+
descriptor: ChartSeries<T>;
|
|
10
|
+
values: Readonly<Record<string, number | null>> | undefined;
|
|
11
|
+
format: (value: number) => string;
|
|
12
|
+
}): ReactElement | null;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { ReactElement, ReactNode } from 'react';
|
|
2
2
|
import { ChartSelection, ChartSeries, ChartTooltipContext } from '../types';
|
|
3
3
|
import { ChartSnapshot } from '../chart-context';
|
|
4
|
+
import { PlotMark } from '../marks/contract';
|
|
5
|
+
/** How the crosshair travels between points; pins travel the same way. */
|
|
6
|
+
export declare const SPRING_TRANSITION: {
|
|
7
|
+
stiffness: number;
|
|
8
|
+
damping: number;
|
|
9
|
+
mass: number;
|
|
10
|
+
};
|
|
4
11
|
interface InspectionLayerProps<T> {
|
|
5
12
|
snapshot: ChartSnapshot<T>;
|
|
6
13
|
selection: ChartSelection<T> | null;
|
|
@@ -24,6 +31,8 @@ interface InspectionLayerProps<T> {
|
|
|
24
31
|
hideAxisBadges?: boolean;
|
|
25
32
|
peer?: boolean;
|
|
26
33
|
onCompareFromHere?: () => void;
|
|
34
|
+
/** Range marks in the plot; column marks draw their own highlight instead of a point. */
|
|
35
|
+
marks?: readonly PlotMark[];
|
|
27
36
|
}
|
|
28
|
-
export declare function InspectionLayer<T>({ snapshot, selection, series, seriesColors, paintId, renderContent, inspectionSeries, stackedPill, pinIcon, tooltipClassName, tooltipAriaLabel, width, height, reducedMotion, highlightMaskId, crossGradientId, compactPlot, inlineOnly, hideAxisBadges, peer, onCompareFromHere, }: InspectionLayerProps<T>): ReactElement;
|
|
37
|
+
export declare function InspectionLayer<T>({ snapshot, selection, series, seriesColors, paintId, renderContent, inspectionSeries, stackedPill, pinIcon, tooltipClassName, tooltipAriaLabel, width, height, reducedMotion, highlightMaskId, crossGradientId, compactPlot, inlineOnly, hideAxisBadges, peer, onCompareFromHere, marks, }: InspectionLayerProps<T>): ReactElement;
|
|
29
38
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Lilt's pin, shared by every control that pins something. With `release`, the struck-through
|
|
4
|
+
* pin waits underneath and takes over on hover or focus, meaning "unpin".
|
|
5
|
+
*/
|
|
6
|
+
export declare function PinGlyphs({ release }: {
|
|
7
|
+
release?: boolean;
|
|
8
|
+
}): ReactElement;
|
|
@@ -3,10 +3,18 @@ export declare const PIN_SIZE = 24;
|
|
|
3
3
|
/**
|
|
4
4
|
* The marker above a pinned crosshair. It fades in with a soft blur, follows the pinned point,
|
|
5
5
|
* and releases the pin when clicked; on hover it shows the release glyph instead of the pin.
|
|
6
|
+
* On a linked chart the pin arrived from elsewhere, so the marker is a ghost of the one that
|
|
7
|
+
* was clicked: it still releases the group's pin, but keyboard users meet only the original.
|
|
6
8
|
*/
|
|
7
|
-
export declare function PinMarker({ left, top, reducedMotion, onRelease, }: {
|
|
9
|
+
export declare function PinMarker({ left, top, reducedMotion, ghost, from, local, onRelease, }: {
|
|
8
10
|
left: number;
|
|
9
11
|
top: number;
|
|
10
12
|
reducedMotion: boolean;
|
|
13
|
+
/** Pinned from a linked chart. */
|
|
14
|
+
ghost?: boolean;
|
|
15
|
+
/** The linked chart's name, for the tooltip. */
|
|
16
|
+
from?: string;
|
|
17
|
+
/** Pinned on this chart only. */
|
|
18
|
+
local?: boolean;
|
|
11
19
|
onRelease: () => void;
|
|
12
20
|
}): ReactElement;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import { ChartSnapshot } from '../chart-context';
|
|
3
|
+
import { NormalizedRow } from '../engine/normalize';
|
|
4
|
+
import { ChartSeries } from '../types';
|
|
5
|
+
/**
|
|
6
|
+
* The private contract every range mark is built on. A mark is an ordinary primitive that
|
|
7
|
+
* draws from the chart context; its spec tells the plot how to lay it out and inspect it.
|
|
8
|
+
* The contract is internal until it has proved itself across several marks.
|
|
9
|
+
*/
|
|
10
|
+
export interface MarkSpec<P> {
|
|
11
|
+
/**
|
|
12
|
+
* `column` marks give each observation a bar-like slot, so the plot insets its edges, and
|
|
13
|
+
* replace the line point with their own highlight on inspection. `overlay` marks, such as a
|
|
14
|
+
* band behind a line, leave layout and inspection to the line.
|
|
15
|
+
*/
|
|
16
|
+
layout: 'column' | 'overlay';
|
|
17
|
+
series: (props: P) => string;
|
|
18
|
+
/** Field IDs the mark reads from its series. */
|
|
19
|
+
fields: (props: P) => readonly string[];
|
|
20
|
+
/** Draws one observation emphasized, over the dimmed marks, while it is inspected. */
|
|
21
|
+
highlight?: (props: P, input: MarkHighlightInput) => ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export interface MarkHighlightInput {
|
|
24
|
+
row: NormalizedRow<unknown>;
|
|
25
|
+
snapshot: ChartSnapshot<unknown>;
|
|
26
|
+
descriptor: ChartSeries<unknown>;
|
|
27
|
+
color: string;
|
|
28
|
+
}
|
|
29
|
+
/** A mark found among a plot's children, with its props bound. */
|
|
30
|
+
export interface PlotMark {
|
|
31
|
+
series: string;
|
|
32
|
+
layout: MarkSpec<unknown>['layout'];
|
|
33
|
+
fields: readonly string[];
|
|
34
|
+
highlight?: (input: MarkHighlightInput) => ReactNode;
|
|
35
|
+
}
|
|
36
|
+
export declare function defineMark<P>(component: (props: P) => ReactElement, spec: MarkSpec<P>): (props: P) => ReactElement;
|
|
37
|
+
/** Marks placed directly in a plot, or inside fragments there, in document order. */
|
|
38
|
+
export declare function collectMarks(children: ReactNode): PlotMark[];
|
|
39
|
+
/** The descriptor a mark draws, after checking it carries every field the mark reads. */
|
|
40
|
+
export declare function markSeries<T>(mark: string, descriptors: readonly ChartSeries<T>[], series: string, fields: readonly string[]): {
|
|
41
|
+
descriptor: ChartSeries<T>;
|
|
42
|
+
index: number;
|
|
43
|
+
};
|
|
44
|
+
/** Field values of one row, or null when any of them is missing. */
|
|
45
|
+
export declare function rowFields(row: NormalizedRow<unknown>, series: string, fields: readonly string[]): number[] | null;
|
|
46
|
+
/** An observation's own color, falling back to the series color. */
|
|
47
|
+
export declare function observationColor<T>(descriptor: ChartSeries<T>, row: NormalizedRow<T>, fallback: string): string;
|
|
48
|
+
/** Rows whose x lies in the visible domain. */
|
|
49
|
+
export declare function rowsInView<T>(snapshot: ChartSnapshot<T>): readonly NormalizedRow<T>[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ChartSnapshot } from '../chart-context';
|
|
2
|
+
import { RangeScales } from '../engine/ranges';
|
|
3
|
+
import { ChartSeries } from '../types';
|
|
4
|
+
export interface RangeMarkState {
|
|
5
|
+
descriptor: ChartSeries<unknown>;
|
|
6
|
+
color: string;
|
|
7
|
+
scales: RangeScales;
|
|
8
|
+
snapshot: ChartSnapshot<unknown>;
|
|
9
|
+
/** Group opacity: hidden, dimmed behind focus or inspection, or full. */
|
|
10
|
+
opacity: number | string;
|
|
11
|
+
/** The reveal mask while the entrance sweeps in. */
|
|
12
|
+
mask: string | undefined;
|
|
13
|
+
clipPath: string;
|
|
14
|
+
reducedMotion: boolean;
|
|
15
|
+
inspecting: boolean;
|
|
16
|
+
}
|
|
17
|
+
export declare function scalesFor(snapshot: ChartSnapshot<unknown>, series: string): RangeScales;
|
|
18
|
+
/** Shared state for a mark drawn from a series' fields. */
|
|
19
|
+
export declare function useRangeMark(mark: string, series: string, fields: readonly string[], layout: 'column' | 'overlay'): RangeMarkState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ChartComparisonResult, ChartPercentagePolicy, ChartController, ChartSeries, ChartYConfig, ChartTooltipContext, NumericXConfig, TimeXConfig, ChartRange } from '../types';
|
|
1
|
+
import { ChartComparisonResult, ChartPercentagePolicy, ChartController, ChartSeries, ChartYConfig, ChartTooltipContext, NumericXConfig, TimeXConfig, ChartRange, ChartPinOptions } from '../types';
|
|
2
2
|
import { LegendSnapshot } from '../runtime/chart-runtime';
|
|
3
3
|
export type CartesianModelLegendItem<Id extends string> = LegendSnapshot['series'][number] & {
|
|
4
4
|
id: Id;
|
|
@@ -63,7 +63,7 @@ export interface CartesianSummaryResult<Id extends string> {
|
|
|
63
63
|
export interface CartesianModelActions<SeriesId extends string> {
|
|
64
64
|
readonly inspect: (x: number) => void;
|
|
65
65
|
readonly clearInspection: () => void;
|
|
66
|
-
readonly pin: (x: number) => void;
|
|
66
|
+
readonly pin: (x: number, options?: ChartPinOptions) => void;
|
|
67
67
|
readonly release: () => void;
|
|
68
68
|
readonly setVisibleSeries: (ids: readonly SeriesId[]) => void;
|
|
69
69
|
readonly focusSeries: (id: SeriesId | null) => void;
|
|
@@ -94,7 +94,7 @@ export interface CartesianChartModel<Row, SeriesId extends string> {
|
|
|
94
94
|
type ModelActions = {
|
|
95
95
|
inspect: (x: number) => void;
|
|
96
96
|
clearInspection: () => void;
|
|
97
|
-
pin: (x: number) => void;
|
|
97
|
+
pin: (x: number, options?: ChartPinOptions) => void;
|
|
98
98
|
release: () => void;
|
|
99
99
|
setVisibleSeries: (ids: readonly string[]) => void;
|
|
100
100
|
focusSeries: (id: string | null) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { AnnotationsProps, ReferenceBandProps } from '../types';
|
|
3
3
|
export declare function Annotations({ items, onSelectionChange, className, }: AnnotationsProps): ReactElement;
|
|
4
|
-
export declare function ReferenceBand({ from, to, label, color, className, }: ReferenceBandProps): ReactElement;
|
|
4
|
+
export declare function ReferenceBand({ from, to, label, color, axis, className, }: ReferenceBandProps): ReactElement;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import { MotionValue } from 'motion/react';
|
|
3
|
+
/** One stop of a segmented axis gradient, low values first. */
|
|
4
|
+
export interface AxisGradientStop {
|
|
5
|
+
color: string;
|
|
6
|
+
opacity?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A segmented axis: rounded segments between ticks instead of one continuous line, with a gap at
|
|
10
|
+
* each tick. With a gradient, one scale runs the length of the axis, low values first, so the
|
|
11
|
+
* axis reads as a range; the segment under the pointer lights up.
|
|
12
|
+
*/
|
|
13
|
+
export declare function AxisSegments({ stops, cross, vertical, gradient, cursor, active, opacity, }: {
|
|
14
|
+
/** Pixel positions that bound the segments, in any order. */
|
|
15
|
+
stops: readonly number[];
|
|
16
|
+
/** Where the segments sit across the axis: x for a vertical axis, y for a horizontal one. */
|
|
17
|
+
cross: number;
|
|
18
|
+
vertical: boolean;
|
|
19
|
+
gradient: readonly AxisGradientStop[] | null;
|
|
20
|
+
cursor: MotionValue<number>;
|
|
21
|
+
active: MotionValue<number>;
|
|
22
|
+
opacity?: number;
|
|
23
|
+
}): ReactElement | null;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ReactElement } from 'react';
|
|
2
2
|
import { IntervalBandProps } from '../types';
|
|
3
|
-
/** A supplied
|
|
4
|
-
export declare
|
|
3
|
+
/** A supplied envelope between two of a line series' fields, e.g. a forecast's low and high. */
|
|
4
|
+
export declare const IntervalBand: (props: IntervalBandProps) => ReactElement;
|