@lilt-ui/charts 0.3.0 → 0.5.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 +45 -0
- package/dist/activity-ring.d.ts +3 -1
- package/dist/cards/activity-ring-card.d.ts +3 -1
- package/dist/cards/bar-chart-card.d.ts +5 -2
- package/dist/cards/box-plot-card.d.ts +3 -1
- package/dist/cards/cartesian-card.d.ts +15 -3
- package/dist/cards/combo-chart-card.d.ts +4 -2
- package/dist/cards/funnel-chart-card.d.ts +26 -2
- package/dist/cards/heatmap-chart-card.d.ts +6 -1
- package/dist/cards/horizontal-bar-chart-card.d.ts +7 -3
- package/dist/cards/progress-card.d.ts +6 -1
- package/dist/cards/radar-chart-card.d.ts +9 -2
- package/dist/cards/radial-chart-card.d.ts +14 -5
- package/dist/cards/range-chart-card.d.ts +3 -1
- package/dist/cards/sankey-chart-card.d.ts +6 -1
- package/dist/cards/scatter-chart-card.d.ts +11 -2
- package/dist/cards/slope-chart-card.d.ts +6 -1
- package/dist/cards/stat-card.d.ts +7 -2
- package/dist/{cartesian-card-Dcd0ZnQL.js → cartesian-card-7DAiMU3w.js} +2112 -1678
- package/dist/engine/depth.d.ts +42 -0
- package/dist/engine/isometric-bars.d.ts +25 -0
- package/dist/engine/ranges.d.ts +31 -0
- package/dist/finance/candle-geometry.d.ts +13 -2
- package/dist/finance/candles.d.ts +5 -0
- package/dist/finance/cards/candlestick-chart-card.d.ts +6 -1
- package/dist/finance/cards/depth-chart-card.d.ts +3 -1
- package/dist/finance/order-book.d.ts +4 -2
- package/dist/finance.js +492 -447
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2349 -1678
- package/dist/interaction/legend-meter.d.ts +11 -0
- package/dist/interaction/use-category-state.d.ts +2 -0
- package/dist/interaction/use-touch-glide.d.ts +26 -0
- package/dist/interaction/value-legend.d.ts +8 -2
- package/dist/marks/use-range-mark.d.ts +8 -0
- package/dist/motion/use-glide.d.ts +7 -3
- package/dist/primitives/depth-paint.d.ts +103 -0
- package/dist/primitives/isometric-bar.d.ts +18 -0
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +30 -4
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared geometry for charts drawn with depth. Every family recedes the same way: up and to the
|
|
3
|
+
* right at about 30°, so a bar, a candle, a ring, and a funnel side by side share one light and
|
|
4
|
+
* one camera. The front face always keeps the measured geometry; depth only adds paint behind it.
|
|
5
|
+
*/
|
|
6
|
+
/** The deepest a column recedes, in pixels. */
|
|
7
|
+
export declare const MAX_DEPTH = 14;
|
|
8
|
+
/** Rise per unit of depth. */
|
|
9
|
+
export declare const DEPTH_SLOPE: number;
|
|
10
|
+
/** Extra paint above the tallest front face; clips reserve this much headroom. */
|
|
11
|
+
export declare const MAX_RISE: number;
|
|
12
|
+
/** Screen offset of the back face for a given depth. */
|
|
13
|
+
export declare function depthOffset(depth: number): {
|
|
14
|
+
dx: number;
|
|
15
|
+
dy: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Depth for a column of a given footprint. Tiny readings and dense charts get proportionately
|
|
19
|
+
* less, never a false minimum.
|
|
20
|
+
*/
|
|
21
|
+
export declare function columnDepth(width: number, height: number): number;
|
|
22
|
+
export interface PrismFaces {
|
|
23
|
+
/** The front, left edge at `x`: the footprint minus the depth, so the prism fits its slot. */
|
|
24
|
+
front: string;
|
|
25
|
+
/** The whole silhouette; drawn first in the side's shade, it also fills every seam. */
|
|
26
|
+
side: string;
|
|
27
|
+
top: string | null;
|
|
28
|
+
frontWidth: number;
|
|
29
|
+
depth: number;
|
|
30
|
+
rise: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* A square prism inside a `width`-wide footprint. The faces overlap underneath the front by a
|
|
34
|
+
* pixel so antialiased edges never show the plot through a seam.
|
|
35
|
+
*/
|
|
36
|
+
export declare function prismFaces(x: number, y: number, width: number, height: number, depth?: number, showTop?: boolean): PrismFaces;
|
|
37
|
+
/**
|
|
38
|
+
* A prism for a column centered on `cx`, such as a range bar or a candle body. The front stays
|
|
39
|
+
* centered on the reading, so the crosshair and any whisker or wick pass through its middle;
|
|
40
|
+
* the depth extends to the right.
|
|
41
|
+
*/
|
|
42
|
+
export declare function centeredPrism(cx: number, y: number, width: number, height: number): PrismFaces;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { barMarkPath, BarGeometry } from './bars';
|
|
2
|
+
/** Extra paint above the measured front face; shared by resting and inspection clips. */
|
|
3
|
+
export declare const ISOMETRIC_BAR_RISE: number;
|
|
4
|
+
type MarkOptions = Parameters<typeof barMarkPath>[1];
|
|
5
|
+
/**
|
|
6
|
+
* A square prism inside the original horizontal slot. The front keeps the real y values; corner
|
|
7
|
+
* radius does not apply, because a rounded front reads as a plate stuck on a box.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isometricBarGeometry(bar: BarGeometry, options: MarkOptions): {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
depth: number;
|
|
15
|
+
rise: number;
|
|
16
|
+
/** Square: an extruded bar has no rounded plate on its front. */
|
|
17
|
+
front: string;
|
|
18
|
+
side: string;
|
|
19
|
+
top: string | null;
|
|
20
|
+
grounded: boolean;
|
|
21
|
+
/** A short contact shadow on the floor band, behind and to the right of the footprint. */
|
|
22
|
+
shadow: string | null;
|
|
23
|
+
cast: number;
|
|
24
|
+
} | null;
|
|
25
|
+
export {};
|
package/dist/engine/ranges.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PrismFaces } from './depth';
|
|
1
2
|
import { NormalizedRow } from './normalize';
|
|
2
3
|
/** Pixel mappings a range mark draws with. */
|
|
3
4
|
export interface RangeScales {
|
|
@@ -29,6 +30,13 @@ export declare class ColorBatches {
|
|
|
29
30
|
d: string;
|
|
30
31
|
}[];
|
|
31
32
|
}
|
|
33
|
+
/** Prism faces batched by color: every side, then every top, then every front. */
|
|
34
|
+
export declare class PrismBatches {
|
|
35
|
+
readonly sides: ColorBatches;
|
|
36
|
+
readonly tops: ColorBatches;
|
|
37
|
+
readonly fronts: ColorBatches;
|
|
38
|
+
add(color: string, faces: PrismFaces): void;
|
|
39
|
+
}
|
|
32
40
|
/** Column geometry shared by candles and range marks: center and body width per row. */
|
|
33
41
|
export declare function columnFrame(scales: RangeScales): {
|
|
34
42
|
width: number;
|
|
@@ -40,6 +48,8 @@ export interface RangeColumn<T> {
|
|
|
40
48
|
}
|
|
41
49
|
/** Rows in view with their pixel centers. */
|
|
42
50
|
export declare function columnsInView<T>(rows: readonly NormalizedRow<T>[], scales: RangeScales): RangeColumn<T>[];
|
|
51
|
+
/** One floating bar from low to high as a prism; its front spans exactly low to high. */
|
|
52
|
+
export declare function rangeBarPrism(cx: number, low: number, high: number, scales: RangeScales): PrismFaces;
|
|
43
53
|
/** One floating bar from low to high. */
|
|
44
54
|
export declare function rangeBarPath(cx: number, low: number, high: number, scales: RangeScales): string;
|
|
45
55
|
/** A whisker from low to high with caps a little narrower than the column. */
|
|
@@ -57,3 +67,24 @@ export declare function boxShape(cx: number, values: {
|
|
|
57
67
|
q3: number;
|
|
58
68
|
max: number;
|
|
59
69
|
}, scales: RangeScales): BoxShape;
|
|
70
|
+
/**
|
|
71
|
+
* A box plot drawn as a solid block. The block's middle, not its front, sits on the reading, so
|
|
72
|
+
* the whiskers run through the center of its top and bottom faces, half the depth back. The
|
|
73
|
+
* front still spans exactly Q1 to Q3, and the median wraps from the front around the side.
|
|
74
|
+
*/
|
|
75
|
+
export declare function boxBlock(cx: number, values: {
|
|
76
|
+
min: number;
|
|
77
|
+
q1: number;
|
|
78
|
+
median: number;
|
|
79
|
+
q3: number;
|
|
80
|
+
max: number;
|
|
81
|
+
}, scales: RangeScales): {
|
|
82
|
+
faces: PrismFaces;
|
|
83
|
+
/** How far the whiskers and outliers sit above their values: half the depth back. */
|
|
84
|
+
lift: number;
|
|
85
|
+
median: string;
|
|
86
|
+
/** Drawn before the block, which hides where it leaves the bottom face. */
|
|
87
|
+
lower: string;
|
|
88
|
+
/** Drawn after the block, rising from the middle of its top face. */
|
|
89
|
+
upper: string;
|
|
90
|
+
};
|
|
@@ -36,6 +36,15 @@ export interface CandlePaths {
|
|
|
36
36
|
color: string;
|
|
37
37
|
d: string;
|
|
38
38
|
}[];
|
|
39
|
+
/** With depth: the receding side and top of every body, one path per color. */
|
|
40
|
+
sides: {
|
|
41
|
+
color: string;
|
|
42
|
+
d: string;
|
|
43
|
+
}[];
|
|
44
|
+
tops: {
|
|
45
|
+
color: string;
|
|
46
|
+
d: string;
|
|
47
|
+
}[];
|
|
39
48
|
}
|
|
40
49
|
export declare function candleAt(row: NormalizedRow<unknown>, series: string, fields: CandleFields): Candle | null;
|
|
41
50
|
/** Throws on a candle whose high or low does not contain its open and close. */
|
|
@@ -44,12 +53,14 @@ interface CandleShape {
|
|
|
44
53
|
body: string | null;
|
|
45
54
|
hollow: string | null;
|
|
46
55
|
stroke: string;
|
|
56
|
+
side: string | null;
|
|
57
|
+
top: string | null;
|
|
47
58
|
}
|
|
48
59
|
/** One candle's geometry. Wicks stop at the body, so a hollow body stays empty. */
|
|
49
|
-
export declare function candleShape(cx: number, candle: Candle, scales: RangeScales, display: CandleDisplay): CandleShape;
|
|
60
|
+
export declare function candleShape(cx: number, candle: Candle, scales: RangeScales, display: CandleDisplay, depth?: boolean): CandleShape;
|
|
50
61
|
/**
|
|
51
62
|
* Every candle in view batched into a handful of paths: bodies, hollow bodies and strokes,
|
|
52
63
|
* each grouped by color. Thousands of candles stay a few DOM nodes.
|
|
53
64
|
*/
|
|
54
|
-
export declare function candlePaths(rows: readonly NormalizedRow<unknown>[], series: string, fields: CandleFields, scales: RangeScales, display: CandleDisplay, colorOf: (row: NormalizedRow<unknown>, candle: Candle) => string): CandlePaths;
|
|
65
|
+
export declare function candlePaths(rows: readonly NormalizedRow<unknown>[], series: string, fields: CandleFields, scales: RangeScales, display: CandleDisplay, colorOf: (row: NormalizedRow<unknown>, candle: Candle) => string, depth?: boolean): CandlePaths;
|
|
55
66
|
export {};
|
|
@@ -9,6 +9,11 @@ export interface CandlesProps {
|
|
|
9
9
|
low: string;
|
|
10
10
|
/** `candle` (default), `hollow` rising bodies, or `ohlc` bars. */
|
|
11
11
|
display?: CandleDisplay;
|
|
12
|
+
/**
|
|
13
|
+
* Draws each body as a solid block receding up and to the right; the front keeps open and
|
|
14
|
+
* close. OHLC bars stay flat.
|
|
15
|
+
*/
|
|
16
|
+
depth?: boolean;
|
|
12
17
|
className?: string;
|
|
13
18
|
}
|
|
14
19
|
/**
|
|
@@ -17,6 +17,11 @@ export interface CandlestickChartCardProps<Row, Key extends NumericKey<Row>> ext
|
|
|
17
17
|
* colored by the period's direction.
|
|
18
18
|
*/
|
|
19
19
|
display?: CandleDisplay | 'area';
|
|
20
|
+
/**
|
|
21
|
+
* Draws each candle body as a solid block receding up and to the right; the front keeps open
|
|
22
|
+
* and close. OHLC bars and the area stay flat.
|
|
23
|
+
*/
|
|
24
|
+
depth?: boolean;
|
|
20
25
|
/** `log` spaces prices by ratio, for long histories. Defaults to `linear`. */
|
|
21
26
|
scale?: 'linear' | 'log';
|
|
22
27
|
/** Names the price series in hover. Defaults to "Price". */
|
|
@@ -37,5 +42,5 @@ export declare function describeCandle(format: (value: number) => string): (insp
|
|
|
37
42
|
* linked volume pane, a headline that follows the hovered candle, and its open, high and low
|
|
38
43
|
* beside the date.
|
|
39
44
|
*/
|
|
40
|
-
export declare function CandlestickChartCard<Row, const Key extends NumericKey<Row>>({ open, high, low, close, volume, display, scale, label, live, data, ranges, delta, valueFormat, locale, volumeHeight, ...props }: CandlestickChartCardProps<Row, Key>): ReactElement;
|
|
45
|
+
export declare function CandlestickChartCard<Row, const Key extends NumericKey<Row>>({ open, high, low, close, volume, display, depth, scale, label, live, data, ranges, delta, valueFormat, locale, volumeHeight, ...props }: CandlestickChartCardProps<Row, Key>): ReactElement;
|
|
41
46
|
export {};
|
|
@@ -8,6 +8,8 @@ export interface DepthChartCardProps {
|
|
|
8
8
|
bids: readonly BookLevel[];
|
|
9
9
|
/** Resting sell orders. */
|
|
10
10
|
asks: readonly BookLevel[];
|
|
11
|
+
/** Draws both sides' edges as lit tubes with a soft shadow; the steps keep their exact prices. */
|
|
12
|
+
depth?: boolean;
|
|
11
13
|
/** Price format for the mid, spread and axis, e.g. `{ style: 'currency', currency: 'USD' }`. */
|
|
12
14
|
valueFormat?: Intl.NumberFormatOptions;
|
|
13
15
|
/** Size format for depth. Defaults to compact numbers. */
|
|
@@ -29,4 +31,4 @@ export interface DepthChartCardProps {
|
|
|
29
31
|
* Order book depth: how much could trade at each price, buying and selling, as stepped areas, with
|
|
30
32
|
* the mid, spread and total depth in the header. Hover reads the size resting at each price.
|
|
31
33
|
*/
|
|
32
|
-
export declare function DepthChartCard({ title, bids, asks, valueFormat, sizeFormat, locale, height, axis, background, hoverStyle, surface, numberStyle, loading, motion, className, style, }: DepthChartCardProps): ReactElement;
|
|
34
|
+
export declare function DepthChartCard({ title, bids, asks, valueFormat, sizeFormat, locale, height, axis, background, hoverStyle, surface, numberStyle, loading, motion, className, style, depth, }: DepthChartCardProps): ReactElement;
|
|
@@ -6,7 +6,9 @@ export interface OrderBookProps {
|
|
|
6
6
|
bids: readonly BookLevel[];
|
|
7
7
|
asks: readonly BookLevel[];
|
|
8
8
|
/** Price levels shown on each side of the spread. Defaults to 8. */
|
|
9
|
-
|
|
9
|
+
levels?: number;
|
|
10
|
+
/** Draws each level's bar as a solid block with a lit roof and a shaded end. */
|
|
11
|
+
depth?: boolean;
|
|
10
12
|
/** Price format, e.g. `{ style: 'currency', currency: 'USD' }`. */
|
|
11
13
|
valueFormat?: Intl.NumberFormatOptions;
|
|
12
14
|
/** Size format. Defaults to compact numbers. */
|
|
@@ -23,4 +25,4 @@ export interface OrderBookProps {
|
|
|
23
25
|
* A price ladder: asks above, bids below, a spread row between, and a depth bar behind each
|
|
24
26
|
* level sized by its running total. It is a real table, so screen readers read it row by row.
|
|
25
27
|
*/
|
|
26
|
-
export declare function OrderBook({ title, bids, asks, depth, valueFormat, sizeFormat, locale, flash, surface, motion, className, style, }: OrderBookProps): ReactElement;
|
|
28
|
+
export declare function OrderBook({ title, bids, asks, levels, depth, valueFormat, sizeFormat, locale, flash, surface, motion, className, style, }: OrderBookProps): ReactElement;
|