react-native-livechart 3.11.0 → 4.0.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/dist/components/BadgeOverlay.d.ts +9 -1
- package/dist/components/BadgeOverlay.d.ts.map +1 -1
- package/dist/components/ChartOverlayLayer.d.ts +19 -0
- package/dist/components/ChartOverlayLayer.d.ts.map +1 -0
- package/dist/components/CustomMarkerOverlay.d.ts +18 -6
- package/dist/components/CustomMarkerOverlay.d.ts.map +1 -1
- package/dist/components/CustomReferenceLineOverlay.d.ts +36 -0
- package/dist/components/CustomReferenceLineOverlay.d.ts.map +1 -0
- package/dist/components/CustomTooltipOverlay.d.ts +5 -2
- package/dist/components/CustomTooltipOverlay.d.ts.map +1 -1
- package/dist/components/DotOverlay.d.ts +7 -1
- package/dist/components/DotOverlay.d.ts.map +1 -1
- package/dist/components/LiveChart.d.ts.map +1 -1
- package/dist/components/LiveChartSeries.d.ts.map +1 -1
- package/dist/components/MarkerOverlay.d.ts +8 -3
- package/dist/components/MarkerOverlay.d.ts.map +1 -1
- package/dist/components/MultiSeriesDots.d.ts +4 -1
- package/dist/components/MultiSeriesDots.d.ts.map +1 -1
- package/dist/components/ReferenceLineGroupOverlay.d.ts +27 -0
- package/dist/components/ReferenceLineGroupOverlay.d.ts.map +1 -0
- package/dist/components/ReferenceLineOverlay.d.ts +25 -2
- package/dist/components/ReferenceLineOverlay.d.ts.map +1 -1
- package/dist/components/XAxisOverlay.d.ts +7 -1
- package/dist/components/XAxisOverlay.d.ts.map +1 -1
- package/dist/components/YAxisOverlay.d.ts +12 -1
- package/dist/components/YAxisOverlay.d.ts.map +1 -1
- package/dist/constants.d.ts +7 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/liveChartEngineTick.d.ts +29 -0
- package/dist/core/liveChartEngineTick.d.ts.map +1 -1
- package/dist/core/liveChartSeriesEngineTick.d.ts +18 -0
- package/dist/core/liveChartSeriesEngineTick.d.ts.map +1 -1
- package/dist/core/resolveConfig.d.ts +56 -2
- package/dist/core/resolveConfig.d.ts.map +1 -1
- package/dist/core/useLiveChartEngine.d.ts +58 -7
- package/dist/core/useLiveChartEngine.d.ts.map +1 -1
- package/dist/core/useLiveChartSeriesEngine.d.ts +8 -2
- package/dist/core/useLiveChartSeriesEngine.d.ts.map +1 -1
- package/dist/draw/grid.d.ts.map +1 -1
- package/dist/draw/markerAtlas.d.ts +20 -2
- package/dist/draw/markerAtlas.d.ts.map +1 -1
- package/dist/draw/volume.d.ts +25 -0
- package/dist/draw/volume.d.ts.map +1 -0
- package/dist/hooks/crosshairShared.d.ts +12 -6
- package/dist/hooks/crosshairShared.d.ts.map +1 -1
- package/dist/hooks/overlayScale.d.ts +22 -0
- package/dist/hooks/overlayScale.d.ts.map +1 -0
- package/dist/hooks/resolveChartLayout.d.ts +9 -0
- package/dist/hooks/resolveChartLayout.d.ts.map +1 -1
- package/dist/hooks/useBadge.d.ts +22 -1
- package/dist/hooks/useBadge.d.ts.map +1 -1
- package/dist/hooks/useCandlePaths.d.ts +6 -0
- package/dist/hooks/useCandlePaths.d.ts.map +1 -1
- package/dist/hooks/useChartOverlayContext.d.ts +45 -0
- package/dist/hooks/useChartOverlayContext.d.ts.map +1 -0
- package/dist/hooks/useChartPaths.d.ts +8 -1
- package/dist/hooks/useChartPaths.d.ts.map +1 -1
- package/dist/hooks/useCrosshair.d.ts +9 -2
- package/dist/hooks/useCrosshair.d.ts.map +1 -1
- package/dist/hooks/useLiveDot.d.ts +6 -1
- package/dist/hooks/useLiveDot.d.ts.map +1 -1
- package/dist/hooks/useMarkers.d.ts +12 -4
- package/dist/hooks/useMarkers.d.ts.map +1 -1
- package/dist/hooks/useMultiSeriesLinePaths.d.ts.map +1 -1
- package/dist/hooks/usePanScroll.d.ts +82 -0
- package/dist/hooks/usePanScroll.d.ts.map +1 -0
- package/dist/hooks/usePinchZoom.d.ts +74 -0
- package/dist/hooks/usePinchZoom.d.ts.map +1 -0
- package/dist/hooks/useReferenceDrag.d.ts +24 -0
- package/dist/hooks/useReferenceDrag.d.ts.map +1 -0
- package/dist/hooks/useReferenceLine.d.ts +23 -4
- package/dist/hooks/useReferenceLine.d.ts.map +1 -1
- package/dist/hooks/useReferenceLinePress.d.ts +5 -1
- package/dist/hooks/useReferenceLinePress.d.ts.map +1 -1
- package/dist/hooks/useVisibleRange.d.ts +39 -0
- package/dist/hooks/useVisibleRange.d.ts.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/math/markerCluster.d.ts +47 -0
- package/dist/math/markerCluster.d.ts.map +1 -0
- package/dist/math/markers.d.ts +15 -0
- package/dist/math/markers.d.ts.map +1 -1
- package/dist/math/referenceDrag.d.ts +24 -0
- package/dist/math/referenceDrag.d.ts.map +1 -0
- package/dist/math/referenceGroup.d.ts +31 -0
- package/dist/math/referenceGroup.d.ts.map +1 -0
- package/dist/math/referenceLines.d.ts +33 -7
- package/dist/math/referenceLines.d.ts.map +1 -1
- package/dist/types.d.ts +512 -21
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/BadgeOverlay.tsx +26 -1
- package/src/components/ChartOverlayLayer.tsx +32 -0
- package/src/components/CustomMarkerOverlay.tsx +153 -53
- package/src/components/CustomReferenceLineOverlay.tsx +250 -0
- package/src/components/CustomTooltipOverlay.tsx +27 -7
- package/src/components/DotOverlay.tsx +9 -0
- package/src/components/LiveChart.tsx +561 -34
- package/src/components/LiveChartSeries.tsx +110 -5
- package/src/components/MarkerOverlay.tsx +100 -6
- package/src/components/MultiSeriesDots.tsx +12 -3
- package/src/components/ReferenceLineGroupOverlay.tsx +207 -0
- package/src/components/ReferenceLineOverlay.tsx +105 -32
- package/src/components/XAxisOverlay.tsx +9 -2
- package/src/components/YAxisOverlay.tsx +48 -26
- package/src/constants.ts +10 -0
- package/src/core/liveChartEngineTick.ts +81 -8
- package/src/core/liveChartSeriesEngineTick.ts +50 -9
- package/src/core/resolveConfig.ts +122 -1
- package/src/core/useLiveChartEngine.ts +103 -10
- package/src/core/useLiveChartSeriesEngine.ts +26 -3
- package/src/draw/grid.ts +13 -1
- package/src/draw/markerAtlas.ts +117 -3
- package/src/draw/volume.ts +190 -0
- package/src/hooks/crosshairShared.ts +37 -9
- package/src/hooks/overlayScale.ts +59 -0
- package/src/hooks/resolveChartLayout.ts +33 -0
- package/src/hooks/useBadge.ts +89 -21
- package/src/hooks/useCandlePaths.ts +104 -7
- package/src/hooks/useChartOverlayContext.ts +93 -0
- package/src/hooks/useChartPaths.ts +14 -1
- package/src/hooks/useCrosshair.ts +29 -2
- package/src/hooks/useLiveDot.ts +16 -5
- package/src/hooks/useMarkers.ts +43 -11
- package/src/hooks/useMultiSeriesLinePaths.ts +2 -1
- package/src/hooks/usePanScroll.ts +253 -0
- package/src/hooks/usePinchZoom.ts +189 -0
- package/src/hooks/useReferenceDrag.ts +254 -0
- package/src/hooks/useReferenceLine.ts +56 -9
- package/src/hooks/useReferenceLinePress.ts +16 -2
- package/src/hooks/useVisibleRange.ts +119 -0
- package/src/index.ts +17 -1
- package/src/math/markerCluster.ts +214 -0
- package/src/math/markers.ts +54 -9
- package/src/math/referenceDrag.ts +66 -0
- package/src/math/referenceGroup.ts +65 -0
- package/src/math/referenceLines.ts +76 -19
- package/src/types.ts +532 -21
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type SharedValue } from "react-native-reanimated";
|
|
2
|
+
import type { ChartEngineLayout } from "../core/useLiveChartEngine";
|
|
3
|
+
import type { ChartPadding } from "../draw/line";
|
|
4
|
+
import type { ChartOverlayContext } from "../types";
|
|
5
|
+
/**
|
|
6
|
+
* Builds the {@link ChartOverlayContext} handed to a custom
|
|
7
|
+
* {@link LiveChartProps.renderOverlay}: a single per-frame {@link ChartScale}
|
|
8
|
+
* SharedValue plus the pure price↔pixel / time↔pixel mapping worklets.
|
|
9
|
+
*
|
|
10
|
+
* The `scale` derived value reads the engine SharedValues (range, window, "now")
|
|
11
|
+
* and the padding each frame, so a consumer's `useAnimatedStyle` becomes reactive
|
|
12
|
+
* just by reading `scale.get()` — that read subscribes it to per-frame updates
|
|
13
|
+
* (Reanimated only observes SharedValues found directly in a worklet's closure,
|
|
14
|
+
* not those hidden behind a function call). The mappings stay pure, taking the
|
|
15
|
+
* snapshot as an argument.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useChartOverlayContext(engine: ChartEngineLayout, padding: ChartPadding): ChartOverlayContext;
|
|
18
|
+
/**
|
|
19
|
+
* Reactive Y for a price: projects `price` to its canvas Y pixel and returns it as
|
|
20
|
+
* a `SharedValue<number>` that tracks the live axis on the UI thread. The
|
|
21
|
+
* **recommended** way to place something at a price in a {@link LiveChartProps.renderOverlay}
|
|
22
|
+
* — read the returned value in your `useAnimatedStyle` like any SharedValue; the
|
|
23
|
+
* subscription to the chart's scale is handled here, so it can't be forgotten.
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* function PriceLevel({ ctx, price }) {
|
|
27
|
+
* const y = usePriceY(ctx, price);
|
|
28
|
+
* const style = useAnimatedStyle(() => ({ transform: [{ translateY: y.get() }] }));
|
|
29
|
+
* return <Animated.View style={style} />;
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* It's a hook, so call it once per level (render one component per price). For
|
|
34
|
+
* one-off math off the render path (e.g. a gesture handler), use the pure
|
|
35
|
+
* {@link ChartOverlayContext.priceToY} with `ctx.scale.get()` instead.
|
|
36
|
+
*/
|
|
37
|
+
export declare function usePriceY(ctx: ChartOverlayContext, price: number): SharedValue<number>;
|
|
38
|
+
/**
|
|
39
|
+
* Reactive X for a timestamp — the time↔pixel sibling of {@link usePriceY}.
|
|
40
|
+
* Projects `time` (unix seconds) to its canvas X pixel as a `SharedValue<number>`
|
|
41
|
+
* that tracks the scrolling window on the UI thread. Read it in your
|
|
42
|
+
* `useAnimatedStyle`; call once per element.
|
|
43
|
+
*/
|
|
44
|
+
export declare function useTimeX(ctx: ChartOverlayContext, time: number): SharedValue<number>;
|
|
45
|
+
//# sourceMappingURL=useChartOverlayContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useChartOverlayContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useChartOverlayContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAc,MAAM,UAAU,CAAC;AAGhE;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,YAAY,GACpB,mBAAmB,CA0BrB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,mBAAmB,EACxB,KAAK,EAAE,MAAM,GACZ,WAAW,CAAC,MAAM,CAAC,CAKrB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,GAAG,EAAE,mBAAmB,EACxB,IAAI,EAAE,MAAM,GACX,WAAW,CAAC,MAAM,CAAC,CAGrB"}
|
|
@@ -18,7 +18,14 @@ export declare function useChartPaths(engine: SingleEngineState, padding: ChartP
|
|
|
18
18
|
* pixel-Y, closed at the threshold instead of the chart baseline. */
|
|
19
19
|
thresholdY?: SharedValue<number>,
|
|
20
20
|
/** Draw the line/fill as a straight polyline instead of the monotone cubic. */
|
|
21
|
-
linear?: boolean
|
|
21
|
+
linear?: boolean,
|
|
22
|
+
/**
|
|
23
|
+
* Value at the visible window's right edge (engine `edgeValue`). With
|
|
24
|
+
* `followViewEdge`, the line's right-edge tip uses this instead of the live
|
|
25
|
+
* `displayValue` — so while time-scrolled the line ends at the last visible
|
|
26
|
+
* price rather than dropping to the (off-screen) live value.
|
|
27
|
+
*/
|
|
28
|
+
edgeValue?: SharedValue<number>, followViewEdge?: boolean): {
|
|
22
29
|
readonly linePath: import("react-native-reanimated").DerivedValue<SkPath>;
|
|
23
30
|
readonly fillPath: import("react-native-reanimated").DerivedValue<SkPath>;
|
|
24
31
|
readonly thresholdFillPath: import("react-native-reanimated").DerivedValue<SkPath>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChartPaths.d.ts","sourceRoot":"","sources":["../../src/hooks/useChartPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAKlE;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;AAC5B;sEACsE;AACtE,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;AAChC,+EAA+E;AAC/E,MAAM,UAAQ;;;;
|
|
1
|
+
{"version":3,"file":"useChartPaths.d.ts","sourceRoot":"","sources":["../../src/hooks/useChartPaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAKlE;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,YAAY,EACrB,MAAM,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;AAC5B;sEACsE;AACtE,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;AAChC,+EAA+E;AAC/E,MAAM,UAAQ;AACd;;;;;GAKG;AACH,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAC/B,cAAc,UAAQ;;;;EA+GvB"}
|
|
@@ -32,11 +32,18 @@ badgeMetrics?: BadgeMetrics,
|
|
|
32
32
|
*/
|
|
33
33
|
deferTapHit?: (x: number, y: number) => boolean,
|
|
34
34
|
/** Where the tooltip pill sits relative to the scrub line. Default `"side"`. */
|
|
35
|
-
tooltipPlacement?: "side" | "top" | "bottom",
|
|
35
|
+
tooltipPlacement?: "side" | "top" | "bottom" | "point",
|
|
36
36
|
/** Render the value row in the default tooltip. Default `true`. */
|
|
37
37
|
tooltipShowValue?: boolean,
|
|
38
38
|
/** Render the time row in the default tooltip. Default `true`. */
|
|
39
39
|
tooltipShowTime?: boolean,
|
|
40
40
|
/** Gap (px) between the tooltip and the plot edge it's pinned to. Default `8`. */
|
|
41
|
-
tooltipMargin?: number
|
|
41
|
+
tooltipMargin?: number,
|
|
42
|
+
/**
|
|
43
|
+
* Height (px) of a bottom band to exclude from scrub recognition — the
|
|
44
|
+
* axis-drag "grab the time ruler" strip, so a drag there scrolls instead of
|
|
45
|
+
* scrubbing (and a vertical drag falls through to the parent). `0` = no
|
|
46
|
+
* exclusion (the default; scrub covers the whole plot).
|
|
47
|
+
*/
|
|
48
|
+
scrubBottomExclude?: number): CrosshairState;
|
|
42
49
|
//# sourceMappingURL=useCrosshair.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCrosshair.d.ts","sourceRoot":"","sources":["../../src/hooks/useCrosshair.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAGj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animated";
|
|
1
2
|
import type { SingleEngineState } from "../core/useLiveChartEngine";
|
|
2
3
|
import type { ChartPadding } from "../draw/line";
|
|
3
4
|
/**
|
|
4
5
|
* Derive the live dot position (right edge of the chart, mapped to current value).
|
|
5
6
|
* Returns `{ dotX, dotY }` as shared values. Coordinates are set to `-100`
|
|
6
7
|
* (off-screen sentinel) when canvas dimensions are unavailable.
|
|
8
|
+
*
|
|
9
|
+
* With `followViewEdge` + `edgeValue`, the dot (and the value line that shares
|
|
10
|
+
* `dotY`) tracks the visible window's right-edge price while scrolled back, so it
|
|
11
|
+
* stays aligned with a `followViewEdge` badge instead of marking the live value.
|
|
7
12
|
*/
|
|
8
|
-
export declare function useLiveDot(engine: SingleEngineState, padding: ChartPadding): {
|
|
13
|
+
export declare function useLiveDot(engine: SingleEngineState, padding: ChartPadding, edgeValue?: SharedValue<number>, followViewEdge?: boolean): {
|
|
9
14
|
readonly dotX: import("react-native-reanimated").DerivedValue<number>;
|
|
10
15
|
readonly dotY: import("react-native-reanimated").DerivedValue<number>;
|
|
11
16
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLiveDot.d.ts","sourceRoot":"","sources":["../../src/hooks/useLiveDot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLiveDot.d.ts","sourceRoot":"","sources":["../../src/hooks/useLiveDot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,YAAY,EACrB,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAC/B,cAAc,UAAQ;;;EAwBvB"}
|
|
@@ -3,14 +3,22 @@ import { type SharedValue } from "react-native-reanimated";
|
|
|
3
3
|
import type { ChartEngineLayout } from "../core/useLiveChartEngine";
|
|
4
4
|
import type { ChartPadding } from "../draw/line";
|
|
5
5
|
import { type ProjectedMarker } from "../math/markers";
|
|
6
|
-
import
|
|
6
|
+
import { type ResolvedMarkerCluster } from "../math/markerCluster";
|
|
7
|
+
import type { LiveChartPoint, Marker, MarkerPressEvent, SeriesConfig } from "../types";
|
|
7
8
|
/**
|
|
8
9
|
* Projects markers to screen positions each frame and builds a tap gesture that
|
|
9
|
-
* hit-tests against them, firing `
|
|
10
|
+
* hit-tests against them, firing `onMarkerPress` (or `null` on a miss). Applies
|
|
11
|
+
* the {@link clusterMarkers} collision pass each frame so hit-testing matches the
|
|
12
|
+
* drawn (stacked / collapsed) positions.
|
|
10
13
|
*/
|
|
11
|
-
export declare function useMarkers(engine: ChartEngineLayout, padding: ChartPadding, markers: SharedValue<Marker[]>, active: boolean, hitRadius: number,
|
|
14
|
+
export declare function useMarkers(engine: ChartEngineLayout, padding: ChartPadding, markers: SharedValue<Marker[]>, active: boolean, hitRadius: number, onMarkerPress?: (event: MarkerPressEvent | null) => void, seriesSV?: SharedValue<SeriesConfig[]>, lineData?: SharedValue<LiveChartPoint[]>,
|
|
12
15
|
/** Static charts run no loops: register without starting. Default `true`. */
|
|
13
|
-
autostart?: boolean
|
|
16
|
+
autostart?: boolean,
|
|
17
|
+
/** Single-series line is drawn linear (`line.curve === "linear"`) — anchor
|
|
18
|
+
* `lineData` markers on the straight chord rather than the spline. */
|
|
19
|
+
lineLinear?: boolean,
|
|
20
|
+
/** Collision config; default `"anchored"` (no stacking). */
|
|
21
|
+
cluster?: ResolvedMarkerCluster): {
|
|
14
22
|
projected: SharedValue<ProjectedMarker[]>;
|
|
15
23
|
tapGesture: ReturnType<typeof Gesture.Tap>;
|
|
16
24
|
/** Worklet hit-test: true when (x, y) lands on a projected marker. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMarkers.d.ts","sourceRoot":"","sources":["../../src/hooks/useMarkers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,YAAY,EACb,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useMarkers.d.ts","sourceRoot":"","sources":["../../src/hooks/useMarkers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAkB,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACV,cAAc,EACd,MAAM,EACN,gBAAgB,EAChB,YAAY,EACb,MAAM,UAAU,CAAC;AASlB;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,EAC9B,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,EACxD,QAAQ,CAAC,EAAE,WAAW,CAAC,YAAY,EAAE,CAAC,EACtC,QAAQ,CAAC,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;AACxC,6EAA6E;AAC7E,SAAS,UAAO;AAChB;uEACuE;AACvE,UAAU,UAAQ;AAClB,4DAA4D;AAC5D,OAAO,GAAE,qBAAwC,GAChD;IACD,SAAS,EAAE,WAAW,CAAC,eAAe,EAAE,CAAC,CAAC;IAC1C,UAAU,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,sEAAsE;IACtE,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C,CAuFA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMultiSeriesLinePaths.d.ts","sourceRoot":"","sources":["../../src/hooks/useMultiSeriesLinePaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAIlE;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,YAAY,GACpB,WAAW,CAAC,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"useMultiSeriesLinePaths.d.ts","sourceRoot":"","sources":["../../src/hooks/useMultiSeriesLinePaths.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAIlE;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,YAAY,GACpB,WAAW,CAAC,MAAM,EAAE,CAAC,CAoDvB"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { Gesture } from "react-native-gesture-handler";
|
|
2
|
+
import { type SharedValue } from "react-native-reanimated";
|
|
3
|
+
import type { ChartPadding } from "../draw/line";
|
|
4
|
+
/** Minimum height (px) of the bottom "grab the time ruler" band in axis-drag mode. */
|
|
5
|
+
export declare const AXIS_GRAB_MIN_PX = 44;
|
|
6
|
+
/** Which gesture activates a time-scroll. */
|
|
7
|
+
export type PanScrollGestureMode = "holdToScrub" | "axisDrag";
|
|
8
|
+
/** Engine SharedValues the pan-scroll gesture reads/writes (subset of the engine state). */
|
|
9
|
+
export interface PanScrollEngineRefs {
|
|
10
|
+
/** Absolute right-edge time to freeze at, or `null` to follow the live edge. */
|
|
11
|
+
viewEnd: SharedValue<number | null>;
|
|
12
|
+
/** Right-edge time the engine would use if following live (advances each frame). */
|
|
13
|
+
liveEdge: SharedValue<number>;
|
|
14
|
+
/** Animating visible window width in seconds. */
|
|
15
|
+
displayWindow: SharedValue<number>;
|
|
16
|
+
/** Canvas width in px. */
|
|
17
|
+
canvasWidth: SharedValue<number>;
|
|
18
|
+
/** Canvas height in px (for the axis-drag band hit-test). */
|
|
19
|
+
canvasHeight: SharedValue<number>;
|
|
20
|
+
}
|
|
21
|
+
export interface UsePanScrollOptions {
|
|
22
|
+
engine: PanScrollEngineRefs;
|
|
23
|
+
padding: ChartPadding;
|
|
24
|
+
/**
|
|
25
|
+
* Earliest selectable time (unix seconds) — typically the first data point /
|
|
26
|
+
* candle. Clamps how far back the window can pan. When there's no scrollable
|
|
27
|
+
* history this should equal (or exceed) the live edge so panning is a no-op.
|
|
28
|
+
*/
|
|
29
|
+
minTime: SharedValue<number>;
|
|
30
|
+
/** Master switch. When false the gesture is disabled and the chart follows live. */
|
|
31
|
+
enabled: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Activation model:
|
|
34
|
+
* - `"holdToScrub"` (default): a one-finger drag anywhere scrolls; scrub moves
|
|
35
|
+
* to press-and-hold (Rainbow-style). The caller must give the scrub gesture
|
|
36
|
+
* a long-press delay so a quick drag falls through to this one.
|
|
37
|
+
* - `"axisDrag"`: a one-finger drag starting in the bottom X-axis band ("grab
|
|
38
|
+
* the time ruler"); one-finger plot scrub untouched.
|
|
39
|
+
*/
|
|
40
|
+
mode?: PanScrollGestureMode;
|
|
41
|
+
/**
|
|
42
|
+
* Worklet fired when a scroll drag activates — e.g. to clear the crosshair so
|
|
43
|
+
* a stray scrub doesn't linger behind the pan.
|
|
44
|
+
*/
|
|
45
|
+
onScrollStart?: () => void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Smallest valid right-edge time: keeps the window's left edge
|
|
49
|
+
* (`rightEdge - window`) from passing `minTime`, and never exceeds the live edge
|
|
50
|
+
* so the `[lo, liveEdge]` clamp range stays valid when history is short.
|
|
51
|
+
*/
|
|
52
|
+
export declare function panLowerBound(minTime: number, windowSecs: number, liveEdge: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Next right-edge time after dragging `changeX` px (drag right ⇒ reveal earlier
|
|
55
|
+
* time ⇒ smaller right edge), clamped to `[lo, liveEdge]`. Returns `null` once
|
|
56
|
+
* the drag reaches the live edge — the signal to resume following.
|
|
57
|
+
*/
|
|
58
|
+
export declare function nextViewEnd(cur: number, changeX: number, chartW: number, windowSecs: number, liveEdge: number, lo: number): number | null;
|
|
59
|
+
/** Pan velocity (px/s) → time-seconds/s for `withDecay` (drag right ⇒ earlier). */
|
|
60
|
+
export declare function flingVelocity(velocityX: number, chartW: number, windowSecs: number): number;
|
|
61
|
+
/**
|
|
62
|
+
* Top y (px) of the axis-drag grab band — a touch at or below this row starts a
|
|
63
|
+
* scroll. The band is the bottom padding (where the time labels sit), widened to
|
|
64
|
+
* a comfortable touch target.
|
|
65
|
+
*/
|
|
66
|
+
export declare function axisBandTop(canvasHeight: number, padBottom: number): number;
|
|
67
|
+
/**
|
|
68
|
+
* Horizontal pan that scrolls the chart back through time. Pick the activation
|
|
69
|
+
* with `mode`:
|
|
70
|
+
* - `"holdToScrub"` — a one-finger drag anywhere (activates on horizontal
|
|
71
|
+
* travel; vertical falls through). Scrub must be press-and-hold so a quick
|
|
72
|
+
* drag races past it (compose with `Gesture.Race`).
|
|
73
|
+
* - `"axisDrag"` — a one-finger drag starting in the bottom X-axis band, gated
|
|
74
|
+
* via `manualActivation` (compose with `Gesture.Exclusive`, this gesture
|
|
75
|
+
* first: outside the band it fails instantly so scrub runs).
|
|
76
|
+
*
|
|
77
|
+
* Writes `engine.viewEnd`: a number freezes the window at that absolute right
|
|
78
|
+
* edge; `null` means "follow live". Dragging (or flinging) back to the live edge
|
|
79
|
+
* resumes following.
|
|
80
|
+
*/
|
|
81
|
+
export declare function usePanScroll({ engine, padding, minTime, enabled, mode, onScrollStart, }: UsePanScrollOptions): ReturnType<typeof Gesture.Pan>;
|
|
82
|
+
//# sourceMappingURL=usePanScroll.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePanScroll.d.ts","sourceRoot":"","sources":["../../src/hooks/usePanScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEjD,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,KAAK,CAAC;AAMnC,6CAA6C;AAC7C,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG,UAAU,CAAC;AAE9D,4FAA4F;AAC5F,MAAM,WAAW,mBAAmB;IAClC,gFAAgF;IAChF,OAAO,EAAE,WAAW,CAAC,MAAM,G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P,OAAO,EACP,OAAO,EACP,IAAoB,EACpB,aAAa,GACd,EAAE,mBAAmB,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,CAoHtD"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Gesture } from "react-native-gesture-handler";
|
|
2
|
+
import { type SharedValue } from "react-native-reanimated";
|
|
3
|
+
import type { ChartPadding } from "../draw/line";
|
|
4
|
+
/** Engine SharedValues the pinch-zoom gesture reads/writes. */
|
|
5
|
+
export interface PinchZoomEngineRefs {
|
|
6
|
+
/** Visible-window width override in seconds, or `null` to follow `timeWindow`. */
|
|
7
|
+
viewWindow: SharedValue<number | null>;
|
|
8
|
+
/** Absolute right-edge time, or `null` to follow the live edge (shared with pan). */
|
|
9
|
+
viewEnd: SharedValue<number | null>;
|
|
10
|
+
/** Right-edge time the engine would use if following live (advances each frame). */
|
|
11
|
+
liveEdge: SharedValue<number>;
|
|
12
|
+
/**
|
|
13
|
+
* Animating visible window width in seconds. Written directly during a pinch so
|
|
14
|
+
* the displayed window tracks the fingers 1:1 (the frame-loop lerp toward
|
|
15
|
+
* `timeWindow` would otherwise lag a fast pinch and the focal anchor would drift).
|
|
16
|
+
*/
|
|
17
|
+
displayWindow: SharedValue<number>;
|
|
18
|
+
/** Canvas width in px. */
|
|
19
|
+
canvasWidth: SharedValue<number>;
|
|
20
|
+
}
|
|
21
|
+
export interface UsePinchZoomOptions {
|
|
22
|
+
engine: PinchZoomEngineRefs;
|
|
23
|
+
padding: ChartPadding;
|
|
24
|
+
/**
|
|
25
|
+
* Earliest selectable time (unix seconds) — typically the first data point /
|
|
26
|
+
* candle. Caps how far the (now wider) window can pan back when zooming out.
|
|
27
|
+
*/
|
|
28
|
+
minTime: SharedValue<number>;
|
|
29
|
+
/** The configured `timeWindow` prop (seconds) — the anchor for the zoom bounds. */
|
|
30
|
+
timeWindow: number;
|
|
31
|
+
/** Master switch. When false the gesture is disabled. */
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
/** Tightest window (max zoom-in), seconds. Default `timeWindow / 8`. */
|
|
34
|
+
minTimeWindow?: number;
|
|
35
|
+
/** Widest window (max zoom-out), seconds. Default: the full data span, ≥ `timeWindow`. */
|
|
36
|
+
maxTimeWindow?: number;
|
|
37
|
+
/** Worklet fired when a pinch activates — e.g. to clear a lingering crosshair. */
|
|
38
|
+
onZoomStart?: () => void;
|
|
39
|
+
}
|
|
40
|
+
/** Clamp a window width to `[minWin, maxWin]`. */
|
|
41
|
+
export declare function clampWindow(win: number, minWin: number, maxWin: number): number;
|
|
42
|
+
/**
|
|
43
|
+
* Resolve the zoom bounds for a gesture. `maxWin` defaults to the data span but
|
|
44
|
+
* never goes below the configured window (so you can always zoom back out to the
|
|
45
|
+
* starting view); `minWin` defaults to an 8× zoom-in of the configured window.
|
|
46
|
+
* Guards against an inverted range (min ≤ max).
|
|
47
|
+
*/
|
|
48
|
+
export declare function zoomWindowBounds(configWindow: number, span: number, minCfg: number | undefined, maxCfg: number | undefined): [number, number];
|
|
49
|
+
/**
|
|
50
|
+
* Absolute time under a pixel x, given the visible window. Inverse of the chart's
|
|
51
|
+
* time→x projection: `x = chartLeft + (t - winStart)/window * chartW`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function focalTime(focalX: number, chartLeft: number, chartW: number, winStart: number, windowSecs: number): number;
|
|
54
|
+
/**
|
|
55
|
+
* The new right-edge time that keeps `focalT` pinned under `focalX` after the
|
|
56
|
+
* window width changes to `newWindow` — i.e. zoom around the focal point. Derived
|
|
57
|
+
* from the projection above by solving for the right edge (`winStart + window`):
|
|
58
|
+
* the right edge sits `(fraction of the window to the right of the focal)` past
|
|
59
|
+
* `focalT`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function zoomViewEnd(focalT: number, focalX: number, chartLeft: number, chartW: number, newWindow: number): number;
|
|
62
|
+
/**
|
|
63
|
+
* Pinch-to-zoom the visible time window, anchored at the focal point between the
|
|
64
|
+
* two fingers (the time under your fingers stays put). Writes `engine.viewWindow`
|
|
65
|
+
* (the window width) and `engine.viewEnd` (the right edge, so the focal anchor
|
|
66
|
+
* holds) — the symmetric counterpart of {@link usePanScroll}, which only moves the
|
|
67
|
+
* right edge. Pinch is two-finger, so it composes with the one-finger pan/scrub
|
|
68
|
+
* via `Gesture.Simultaneous`.
|
|
69
|
+
*
|
|
70
|
+
* Reaching the live edge resumes following (`viewEnd → null`); the zoom level
|
|
71
|
+
* (`viewWindow`) is independent of scroll position and persists.
|
|
72
|
+
*/
|
|
73
|
+
export declare function usePinchZoom({ engine, padding, minTime, timeWindow, enabled, minTimeWindow, maxTimeWindow, onZoomStart, }: UsePinchZoomOptions): ReturnType<typeof Gesture.Pinch>;
|
|
74
|
+
//# sourceMappingURL=usePinchZoom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePinchZoom.d.ts","sourceRoot":"","sources":["../../src/hooks/usePinchZoom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAGjD,+DAA+D;AAC/D,MAAM,WAAW,mBAAmB;IAClC,kFAAkF;IAClF,UAAU,EAAE,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACvC,qFAAqF;IACrF,OAAO,EAAE,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACpC,oFAAoF;IACpF,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B;;;;OAIG;IACH,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,0BAA0B;IAC1B,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,mBAAmB,CAAC;IAC5B,OAAO,EAAE,YAAY,CAAC;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
+
import { Gesture } from "react-native-gesture-handler";
|
|
2
|
+
import { type SharedValue } from "react-native-reanimated";
|
|
3
|
+
import type { ChartEngineLayout } from "../core/useLiveChartEngine";
|
|
4
|
+
import type { ChartPadding } from "../draw/line";
|
|
5
|
+
import type { ReferenceLine } from "../types";
|
|
6
|
+
/**
|
|
7
|
+
* Builds the per-line **drag** gesture for draggable Form-A reference lines: grab a
|
|
8
|
+
* line near its value-Y and drag vertically to set a new value, with optional
|
|
9
|
+
* `snap` + `bounds` clamp. Mirrors the order-ticket reticle in {@link useCrosshair}
|
|
10
|
+
* (value↔Y via `computeValueAtY` / `computeScrubDotY`, frozen value re-projected
|
|
11
|
+
* each frame) but per line, writing into the shared `dragValues` array the layout
|
|
12
|
+
* and overlays read.
|
|
13
|
+
*
|
|
14
|
+
* The pan uses `manualActivation`: it grabs only when a touch starts within
|
|
15
|
+
* {@link GRAB_SLOP} of a draggable line **and** the motion is vertical — a
|
|
16
|
+
* horizontal drag (scrub) or a touch off every line fails fast so the chart's other
|
|
17
|
+
* gestures run (compose this ahead of them via `Gesture.Exclusive`).
|
|
18
|
+
*
|
|
19
|
+
* Also fires the per-line drag callbacks: `onChange` (de-duped during drag),
|
|
20
|
+
* `onCommit` (on release), and `onDragIn` / `onDragOut` (value crossing the visible
|
|
21
|
+
* range or a `bounds`, from a drag or the axis rescaling — edge-detected each frame).
|
|
22
|
+
*/
|
|
23
|
+
export declare function useReferenceDrag(engine: ChartEngineLayout, padding: ChartPadding, lines: ReferenceLine[], dragValues: SharedValue<number[]>, dragActive: SharedValue<boolean[]>, enabled: boolean): ReturnType<typeof Gesture.Pan>;
|
|
24
|
+
//# sourceMappingURL=useReferenceDrag.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReferenceDrag.d.ts","sourceRoot":"","sources":["../../src/hooks/useReferenceDrag.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAOjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAgB9C;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,aAAa,EAAE,EACtB,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,EACjC,UAAU,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC,EAClC,OAAO,EAAE,OAAO,GACf,UAAU,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,CAoMhC"}
|
|
@@ -10,10 +10,20 @@ export interface ReferenceLineLayout {
|
|
|
10
10
|
y: number;
|
|
11
11
|
/** Band bottom-edge y (value/time band); equals `y` for a plain line. */
|
|
12
12
|
yBottom: number;
|
|
13
|
-
/** Left x extent. */
|
|
13
|
+
/** Left x extent of the plot (badge / label / connector anchor). */
|
|
14
14
|
x1: number;
|
|
15
|
-
/** Right x extent. */
|
|
15
|
+
/** Right x extent of the plot (badge / label / connector anchor). */
|
|
16
16
|
x2: number;
|
|
17
|
+
/**
|
|
18
|
+
* Left x of the **drawn** line / band. Equals {@link x1} normally, or `0`
|
|
19
|
+
* (canvas edge) when the line is full-width. Decoupled from {@link x1} so the
|
|
20
|
+
* line can run through the gutter while the badge/label stays in the plot.
|
|
21
|
+
*/
|
|
22
|
+
lineX1: number;
|
|
23
|
+
/** Right x of the drawn line / band: {@link x2} normally, or the canvas width when full-width. */
|
|
24
|
+
lineX2: number;
|
|
25
|
+
/** Stroke the plain horizontal line (true for a plain Form-A line, or a full-width badged line). */
|
|
26
|
+
drawLine: boolean;
|
|
17
27
|
/** Resolved label text (with appended value when `showValue`); "" when hidden. */
|
|
18
28
|
label: string;
|
|
19
29
|
labelX: number;
|
|
@@ -54,12 +64,21 @@ export interface ReferenceBadgeRect {
|
|
|
54
64
|
* {@link useReferenceLine}, so the hit-target tracks the rendered pill exactly.
|
|
55
65
|
* Pure worklet — used by {@link useReferenceLinePress} for tap hit-testing.
|
|
56
66
|
*/
|
|
57
|
-
export declare function computeReferenceBadgeRect(line: ReferenceLine, canvasWidth: number, canvasHeight: number, padding: ChartPadding, dMin: number, dMax: number, font: SkFont, formatValue: (value: number) => string
|
|
67
|
+
export declare function computeReferenceBadgeRect(line: ReferenceLine, canvasWidth: number, canvasHeight: number, padding: ChartPadding, dMin: number, dMax: number, font: SkFont, formatValue: (value: number) => string,
|
|
68
|
+
/** Live value override (e.g. a dragged value), defaulting to `line.value`. */
|
|
69
|
+
valueOverride?: number): ReferenceBadgeRect | null;
|
|
58
70
|
/**
|
|
59
71
|
* Derives screen-space layout for a single reference line or band. Supports all
|
|
60
72
|
* three `ReferenceLine` forms (horizontal line, horizontal value band, vertical
|
|
61
73
|
* time band) plus the pill badge for a Form-A value (in-range tag + off-screen
|
|
62
74
|
* chevron pin).
|
|
63
75
|
*/
|
|
64
|
-
export declare function useReferenceLine(engine: ChartEngineLayout, padding: ChartPadding, line: ReferenceLine | undefined, formatValue: (v: number) => string, font: SkFont
|
|
76
|
+
export declare function useReferenceLine(engine: ChartEngineLayout, padding: ChartPadding, line: ReferenceLine | undefined, formatValue: (v: number) => string, font: SkFont,
|
|
77
|
+
/**
|
|
78
|
+
* Per-line live value overrides (e.g. dragged values), index-aligned with the
|
|
79
|
+
* chart's `referenceLines`. When provided and the slot at {@link index} holds a
|
|
80
|
+
* number, the Form-A line tracks that value instead of the static `line.value`,
|
|
81
|
+
* so a drag updates the rendered line/badge on the UI thread. Omit for static lines.
|
|
82
|
+
*/
|
|
83
|
+
dragValues?: SharedValue<number[]>, index?: number): SharedValue<ReferenceLineLayout>;
|
|
65
84
|
//# sourceMappingURL=useReferenceLine.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReferenceLine.d.ts","sourceRoot":"","sources":["../../src/hooks/useReferenceLine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAOjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,kFAAkF;AAClF,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,
|
|
1
|
+
{"version":3,"file":"useReferenceLine.d.ts","sourceRoot":"","sources":["../../src/hooks/useReferenceLine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAOjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,kFAAkF;AAClF,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,CAAC,EAAE,MAAM,CAAC;IACV,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,oEAAoE;IACpE,EAAE,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,EAAE,EAAE,MAAM,CAAC;IACX;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;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AY,EACrB,IAAI,EAAE,aAAa,GAAG,SAAS,EAC/B,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAClC,IAAI,EAAE,MAAM;AACZ;;;;;GAKG;AACH,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,EAClC,KAAK,SAAI,GACR,WAAW,CAAC,mBAAmB,CAAC,CAgNlC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SkFont } from "@shopify/react-native-skia";
|
|
2
2
|
import { Gesture } from "react-native-gesture-handler";
|
|
3
|
+
import { type SharedValue } from "react-native-reanimated";
|
|
3
4
|
import type { ChartEngineLayout } from "../core/useLiveChartEngine";
|
|
4
5
|
import type { ChartPadding } from "../draw/line";
|
|
5
6
|
import type { ReferenceLine } from "../types";
|
|
@@ -16,7 +17,10 @@ import type { ReferenceLine } from "../types";
|
|
|
16
17
|
*/
|
|
17
18
|
export declare function useReferenceLinePress(engine: ChartEngineLayout, padding: ChartPadding, lines: ReferenceLine[], font: SkFont, formatValue: (v: number) => string, active: boolean,
|
|
18
19
|
/** Touch-target inflation around each pill, in px. */
|
|
19
|
-
hitSlop: number, onPress?: (line: ReferenceLine, index: number) => void
|
|
20
|
+
hitSlop: number, onPress?: (line: ReferenceLine, index: number) => void,
|
|
21
|
+
/** Per-line live value overrides (dragged values) so a draggable line's hit-rect
|
|
22
|
+
* tracks the drag, index-aligned with `lines`. */
|
|
23
|
+
dragValues?: SharedValue<number[]>): {
|
|
20
24
|
tapGesture: ReturnType<typeof Gesture.Tap>;
|
|
21
25
|
hitTest: (x: number, y: number) => boolean;
|
|
22
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReferenceLinePress.d.ts","sourceRoot":"","sources":["../../src/hooks/useReferenceLinePress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"useReferenceLinePress.d.ts","sourceRoot":"","sources":["../../src/hooks/useReferenceLinePress.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAO9C;;;;;;;;;;GAUG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,aAAa,EAAE,EACtB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,EAClC,MAAM,EAAE,OAAO;AACf,sDAAsD;AACtD,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI;AACtD;mDACmD;AACnD,UAAU,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,GACjC;IACD,UAAU,EAAE,UAAU,CAAC,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;CAC5C,CAgEA"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type SharedValue } from "react-native-reanimated";
|
|
2
|
+
import type { VisibleRange } from "../types";
|
|
3
|
+
export type { VisibleRange };
|
|
4
|
+
/** Engine SharedValues the visible-range reaction reads. */
|
|
5
|
+
export interface VisibleRangeEngineRefs {
|
|
6
|
+
timestamp: SharedValue<number>;
|
|
7
|
+
displayWindow: SharedValue<number>;
|
|
8
|
+
viewEnd: SharedValue<number | null>;
|
|
9
|
+
}
|
|
10
|
+
export interface UseVisibleRangeOptions {
|
|
11
|
+
engine: VisibleRangeEngineRefs;
|
|
12
|
+
/** Earliest retained time (unix seconds) — used for the `onReachStart` trigger. */
|
|
13
|
+
minTime: SharedValue<number>;
|
|
14
|
+
/** Fires (throttled to ~1 Hz) when the visible window's edges change. */
|
|
15
|
+
onVisibleRangeChange?: (range: VisibleRange) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Fires once when the window's left edge comes within one window-width of the
|
|
18
|
+
* earliest retained data — the cue to lazily page in older history. Re-arms
|
|
19
|
+
* after the edge moves back out.
|
|
20
|
+
*/
|
|
21
|
+
onReachStart?: () => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Throttle key for a visible range: integer seconds of each edge plus the
|
|
25
|
+
* near-start flag. The reaction emits only when this changes, so a live chart
|
|
26
|
+
* (whose right edge slides every frame) notifies at most ~once per second rather
|
|
27
|
+
* than per frame, and `onReachStart` edge-triggers off the trailing flag.
|
|
28
|
+
*/
|
|
29
|
+
export declare function rangeSignature(startSec: number, endSec: number, near: boolean): string;
|
|
30
|
+
/** Whether the window's left edge is within `threshold` seconds of the oldest data. */
|
|
31
|
+
export declare function isNearStart(winStart: number, minTime: number, threshold: number): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Bridges the UI-thread visible window to JS paging callbacks. A reaction watches
|
|
34
|
+
* the window edges and `scheduleOnRN`s `onVisibleRangeChange` (throttled) and
|
|
35
|
+
* `onReachStart` (edge-triggered near the oldest data). Inert when both callbacks
|
|
36
|
+
* are absent. Used by both `LiveChart` and `LiveChartSeries`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function useVisibleRange({ engine, minTime, onVisibleRangeChange, onReachStart, }: UseVisibleRangeOptions): void;
|
|
39
|
+
//# sourceMappingURL=useVisibleRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVisibleRange.d.ts","sourceRoot":"","sources":["../../src/hooks/useVisibleRange.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,YAAY,EAAE,YAAY,EAAE,CAAC;AAE7B,4DAA4D;AAC5D,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC/B,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,OAAO,EAAE,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,mFAAmF;IACnF,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,yEAAyE;IACzE,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IACrD;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,GACZ,MAAM,CAGR;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CACzB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAChB,OAAO,CAGT;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,EAC9B,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,YAAY,GACb,EAAE,sBAAsB,GAAG,IAAI,CAkD/B"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,5 +14,6 @@ export { formatTime, formatValue } from "./lib/format";
|
|
|
14
14
|
export { MONO_FONT_FAMILY } from "./lib/monoFontFamily";
|
|
15
15
|
export { useDegen } from "./hooks/useDegen";
|
|
16
16
|
export { useTradeStream } from "./hooks/useTradeStream";
|
|
17
|
-
export
|
|
17
|
+
export { usePriceY, useTimeX } from "./hooks/useChartOverlayContext";
|
|
18
|
+
export type { AreaDotsConfig, AxisLabelConfig, BadgeConfig, BadgeMetrics, BadgeStyleConfig, BadgeVariant, CandleMetrics, CandlePoint, ChartInsets, ChartOverlayContext, ChartPlotRect, ChartScale, ChartSegment, DegenOptions, DegenShakePayload, EmptyStateMetrics, FontConfig, FontWeight, GradientConfig, GridMetrics, GridStyleConfig, LeftEdgeFadeConfig, LegendConfig, LegendStyle, LineConfig, LiveChartCoreProps, LiveChartMetrics, LiveChartMetricsOverride, LiveChartPalette, LiveChartPoint, LiveChartProps, LiveChartSeriesProps, Marker, MarkerClusterConfig, MarkerKind, MarkerPressEvent, MarkerRenderContext, MarkerSide, Momentum, MomentumConfig, MotionMetrics, MultiSeriesDotConfig, PulseConfig, ReferenceLine, ReferenceLineBadgeConfig, ReferenceLineGroupingConfig, ReferenceLineRenderProps, ScrubActionConfig, ScrubActionPoint, ScrubConfig, ScrubPoint, ScrubPointCore, ScrubPointMulti, ScrubSeriesValue, SelectionDotConfig, SelectionDotProps, SelectionDotRingConfig, SeriesConfig, ThemeMode, ThresholdConfig, ThresholdLineConfig, TooltipRenderProps, TradeEvent, ValueLineConfig, VisibleRange, VolumeConfig, XAxisConfig, YAxisConfig, ZoomConfig, } from "./types";
|
|
18
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC;AAC3D,YAAY,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAIjF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD,YAAY,EACV,cAAc,EACd,eAAe,EACf,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,eAAe,EACf,kBAAkB,EAClB,YAAY,EACZ,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,wBAAwB,EACxB,gBAAgB,EAChB,cAAc,EACd,cAAc,EACd,oBAAoB,EACpB,MAAM,EACN,gBAAgB,EAChB,UAAU,EACV,QAAQ,EACR,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EACjB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,YAAY,EACZ,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,WAAW,EACX,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,eAAe,E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AAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,UAAU,EACV,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { Marker } from "../types";
|
|
2
|
+
import type { ProjectedMarker } from "./markers";
|
|
3
|
+
/**
|
|
4
|
+
* Resolved {@link LiveChartProps.markerCluster} config (see `resolveMarkerCluster`).
|
|
5
|
+
*/
|
|
6
|
+
export interface ResolvedMarkerCluster {
|
|
7
|
+
/** `"anchored"` = no collision handling (glyphs overlap). `"stacked"` = fan +
|
|
8
|
+
* collapse co-located markers. */
|
|
9
|
+
mode: "anchored" | "stacked";
|
|
10
|
+
/** Fraction (0–1) that adjacent co-located glyphs overlap when fanned. The fan
|
|
11
|
+
* step is `glyphHeight * (1 - overlap)`; `glyphHeight` is a slightly generous
|
|
12
|
+
* primitive estimate, so the *visible* overlap runs a touch lower. */
|
|
13
|
+
overlap: number;
|
|
14
|
+
/** Extra px between a sided glyph and its anchor. */
|
|
15
|
+
gap: number;
|
|
16
|
+
/** Collapse a co-located run to a single count badge once it exceeds this many. */
|
|
17
|
+
maxBeforeGroup: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ClusterMarkersOpts {
|
|
20
|
+
config: ResolvedMarkerCluster;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Estimated vertical (≈ horizontal) footprint of a marker glyph in px. Derived
|
|
24
|
+
* from primitives only (no font metrics / atlas), so the hit-test hook and the
|
|
25
|
+
* overlays compute identical offsets from identical inputs — keeping the drawn
|
|
26
|
+
* and hit-tested positions in sync. Not pixel-exact with the atlas cell; the
|
|
27
|
+
* generous default `markerHitRadius` absorbs the small difference.
|
|
28
|
+
*/
|
|
29
|
+
export declare function glyphHeight(m: Marker): number;
|
|
30
|
+
/**
|
|
31
|
+
* Collision pass over projected markers, mutating `proj` in place.
|
|
32
|
+
*
|
|
33
|
+
* `"anchored"` mode only applies each marker's {@link Marker.side} offset (a lone
|
|
34
|
+
* glyph sitting above/below its anchor); it does no bucketing, so charts that
|
|
35
|
+
* don't use `side` are untouched. `"stacked"` mode additionally buckets
|
|
36
|
+
* co-located markers (same side, overlapping x/y) and fans or collapses them.
|
|
37
|
+
*
|
|
38
|
+
* Runs every frame on the UI thread, so grouping is zoom/scroll-reactive. Reads
|
|
39
|
+
* the *raw* projected positions from `projectMarkers` and overwrites them.
|
|
40
|
+
*/
|
|
41
|
+
export declare function clusterMarkers(markers: Marker[], proj: ProjectedMarker[], opts: ClusterMarkersOpts): void;
|
|
42
|
+
/**
|
|
43
|
+
* Markers belonging to the collapsed cluster whose representative is `repIndex`
|
|
44
|
+
* (ordered by time). Call after {@link clusterMarkers} has populated `proj`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function clusterMembers(markers: Marker[], proj: ProjectedMarker[], repIndex: number): Marker[];
|
|
47
|
+
//# sourceMappingURL=markerCluster.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markerCluster.d.ts","sourceRoot":"","sources":["../../src/math/markerCluster.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAc,MAAM,UAAU,CAAC;AACnD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;uCACmC;IACnC,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;IAC7B;;2EAEuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ,mFAAmF;IACnF,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,qBAAqB,CAAC;CAC/B;AAKD;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAK7C;AA4FD;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,eAAe,EAAE,EACvB,IAAI,EAAE,kBAAkB,GACvB,IAAI,CAiDN;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,MAAM,EAAE,EACjB,IAAI,EAAE,eAAe,EAAE,EACvB,QAAQ,EAAE,MAAM,GACf,MAAM,EAAE,CAQV"}
|
package/dist/math/markers.d.ts
CHANGED
|
@@ -4,6 +4,16 @@ export interface ProjectedMarker {
|
|
|
4
4
|
x: number;
|
|
5
5
|
y: number;
|
|
6
6
|
visible: boolean;
|
|
7
|
+
/** Collapsed cluster member that the representative stands in for — not drawn,
|
|
8
|
+
* not hit-tested. Set by the cluster pass; `false` outside `markerCluster`. */
|
|
9
|
+
hidden: boolean;
|
|
10
|
+
/** This marker is the representative (count badge) of a collapsed cluster. */
|
|
11
|
+
isGrouped: boolean;
|
|
12
|
+
/** Size of the collapsed cluster this marker represents (`0` when not grouped). */
|
|
13
|
+
groupCount: number;
|
|
14
|
+
/** Index of the cluster's representative marker for collapsed members (and the
|
|
15
|
+
* representative itself), else `-1`. Used to gather members on tap. */
|
|
16
|
+
groupRep: number;
|
|
7
17
|
}
|
|
8
18
|
export interface ProjectMarkersOpts {
|
|
9
19
|
canvasWidth: number;
|
|
@@ -20,6 +30,11 @@ export interface ProjectMarkersOpts {
|
|
|
20
30
|
series?: SeriesConfig[];
|
|
21
31
|
/** Single-series line data; anchors markers that omit `value` (and `seriesId`). */
|
|
22
32
|
lineData?: LiveChartPoint[];
|
|
33
|
+
/** When the single-series line is drawn with `line.curve === "linear"`, anchor
|
|
34
|
+
* `lineData` markers on the straight chord (linear interpolation) instead of the
|
|
35
|
+
* monotone spline so the glyph sits exactly on the rendered line. Multi-series
|
|
36
|
+
* markers read their curve per-series from {@link SeriesConfig.curve}. */
|
|
37
|
+
lineLinear?: boolean;
|
|
23
38
|
}
|
|
24
39
|
/**
|
|
25
40
|
* Project markers to screen positions, mutating `out` in place (reused buffer).
|