@supersolutions/super-chart-react-native 0.0.0 → 0.17.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/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Super Chart for React Native
2
+
3
+ A native financial chart view for iOS and Android. The application supplies OHLCV bars with Unix millisecond timestamps and gives the view a height. The host supplies React Native with Fabric, React, native SVG, Gesture Handler 3, Reanimated 4 and a matching Worklets runtime. See the exact peer ranges in the package manifest. Rebuild the app after installing native peers. Bare React Native hosts must put `react-native-worklets/plugin` last in the Babel plugins list. [Reanimated installation](https://docs.swmansion.com/react-native-reanimated/docs/fundamentals/getting-started/)
4
+
5
+ ```tsx
6
+ import { SuperChart, type MarketBar } from '@supersolutions/super-chart-react-native'
7
+
8
+ export function PriceChart({ bars }: { bars: MarketBar[] }) {
9
+ return <SuperChart symbol="BTC/USD" period="1h" bars={bars} style={{ height: 320 }} />
10
+ }
11
+ ```
12
+
13
+ Drag horizontally for history, release to coast, pinch around a point of interest or hold a candle to inspect it. Drag the price axis vertically to change its range and double-tap the axis to return to automatic scaling. During a horizontal drag, the UI thread moves a strip with one extra plot width on each side. JavaScript replenishes the strip as it approaches an edge. Set `interactionMode` for an embedded chart, provide `onInspect` for a custom quote header and use `onChartPress` for host interaction. The same core powers technical indicators, viewport math, drawings and AI annotation templates across platforms.
14
+
15
+ While placing a drawing anchor, drag to aim with the offset crosshair and magnifier. Nearby candle open, high, low and close values provide snap targets. Set `drawingMagnet={false}` for unrestricted placement.
16
+
17
+ Use `annotations` for host-owned AI marks and `markers` for time-and-price events. Avatars share stable candle-index buckets at a given zoom. Overlapping AI labels expose a count that opens the full list. Screen-reader users can focus the visible groups and annotations. `onMarkerPress` receives its members so the app can show a native sheet. Keep market selection, authentication, networking, AI prompts, persistent storage and source links in the host.
18
+
19
+ Run the [standalone Expo example](https://github.com/Super-Solution/super-chart/tree/main/examples/react-native) to try the package from a checkout.
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import type { DrawingBounds, DrawingPoint } from '@supersolutions/super-chart-core';
3
+ import type { MarkerCluster, NativeAnnotation, NativeChartMarker, ProjectedAnnotation } from './overlaysModel';
4
+ export declare function annotationDescription(annotation: NativeAnnotation, precision: number, locale?: string): string;
5
+ interface Props {
6
+ bounds: DrawingBounds;
7
+ offsetX: number;
8
+ clusters: readonly MarkerCluster[];
9
+ annotations: readonly {
10
+ entry: ProjectedAnnotation;
11
+ point: DrawingPoint;
12
+ }[];
13
+ hidden: readonly NativeAnnotation[];
14
+ choices: readonly NativeAnnotation[] | null;
15
+ choose: (entries: readonly NativeAnnotation[] | null) => void;
16
+ onMarkerPress?: (members: readonly NativeChartMarker[]) => void;
17
+ onAnnotationPress?: (entry: NativeAnnotation) => void;
18
+ locale?: string;
19
+ precision: number;
20
+ ink: string;
21
+ surface: string;
22
+ }
23
+ export declare function LayerControls(props: Props): React.JSX.Element;
24
+ export {};
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { DrawingPoint, EngineFrame } from '@supersolutions/super-chart-core';
3
+ import type { ChartTheme } from './model';
4
+ export declare function PrecisionGuide({ frame, point, theme, precision, locale, fontScale }: {
5
+ frame: EngineFrame;
6
+ point: DrawingPoint;
7
+ theme: ChartTheme;
8
+ precision: number;
9
+ locale?: string;
10
+ fontScale: number;
11
+ }): React.JSX.Element;
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { type StyleProp, type ViewStyle } from 'react-native';
3
+ import { type DrawingPoint, type EngineFrame, type EngineIndicatorSpec, type IndicatorDefinition, type MarketBar, type PriceScaleOptions, type Timespan } from '@supersolutions/super-chart-core';
4
+ import { type InteractionMode } from './gestures';
5
+ import { type ChartTheme, type NativeChartMode } from './model';
6
+ import { type NativeLayerProps } from './overlays';
7
+ export interface SuperChartProps extends NativeLayerProps {
8
+ /** Ascending or unordered OHLCV history. Timestamps are Unix milliseconds. Replace the array on updates. */
9
+ bars: readonly MarketBar[];
10
+ symbol: string;
11
+ period: string;
12
+ mode?: NativeChartMode;
13
+ indicators?: readonly EngineIndicatorSpec[];
14
+ /** Optional technical catalog entries or consumer-defined indicators. */
15
+ indicatorDefinitions?: readonly IndicatorDefinition[];
16
+ showVolume?: boolean;
17
+ showLegend?: boolean;
18
+ priceScale?: PriceScaleOptions;
19
+ precision?: number;
20
+ locale?: string;
21
+ timeZone?: string;
22
+ symbolTimezone?: string;
23
+ timespan?: Timespan;
24
+ theme?: Partial<ChartTheme>;
25
+ interactionMode?: InteractionMode;
26
+ style?: StyleProp<ViewStyle>;
27
+ accessibilityLabel?: string;
28
+ emptyLabel?: string;
29
+ testID?: string;
30
+ onInspect?: (bar: MarketBar | null) => void;
31
+ onChartPress?: (point: DrawingPoint, frame: EngineFrame) => void;
32
+ /** Add SVG content in plot coordinates, clipped to the price pane. */
33
+ renderOverlay?: (frame: EngineFrame) => React.ReactNode;
34
+ }
35
+ export interface SuperChartHandle {
36
+ resetViewport: () => void;
37
+ zoom: (factor: number) => void;
38
+ finishPath: () => void;
39
+ clearInspection: () => void;
40
+ }
41
+ /** Changing the instrument or aggregation starts a fresh viewport and dismisses transient interaction state. */
42
+ export declare const SuperChart: React.ForwardRefExoticComponent<SuperChartProps & React.RefAttributes<SuperChartHandle>>;
@@ -0,0 +1,7 @@
1
+ /** Coalesce native image prefetches across surfaces and allow failed requests to retry. */
2
+ export declare class AvatarCache {
3
+ private readonly limit;
4
+ private readonly entries;
5
+ constructor(limit?: number);
6
+ warm(uri: string, fetch: (uri: string) => Promise<boolean>, now?: () => number): void;
7
+ }
@@ -0,0 +1,12 @@
1
+ import { type EngineFrame, type EngineLayout, type FrameIndicator, type MarketBar, type PriceScaleOptions } from '@supersolutions/super-chart-core';
2
+ /** Each side keeps one plot width, at exactly the visible bar pitch and price scale. */
3
+ export declare function bufferedFrame(visible: EngineFrame, width: number, height: number, raw: readonly MarketBar[], display: readonly MarketBar[], studies: FrameIndicator[], layout: EngineLayout): {
4
+ frame: EngineFrame;
5
+ extra: number;
6
+ width: number;
7
+ };
8
+ /** Keep the price at the original finger height fixed. Log ranges must be scaled in log space. */
9
+ export declare function dragPriceRange(range: readonly [number, number], fractionFromLow: number, delta: number, height: number, mode: PriceScaleOptions['mode']): readonly [number, number];
10
+ /** Limit painting to pixels actually present while a replacement buffer is in flight on JS. */
11
+ export declare function bufferTranslation(renderedStart: number, camera: number, scale: number, extra: number): number;
12
+ export declare function panStartAt(start: number, delta: number, pixelsPerBar: number, maximum: number): number;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import type { DrawingGeometry, DrawingPoint } from '@supersolutions/super-chart-core';
3
+ export declare function linePath(points: readonly DrawingPoint[]): string;
4
+ /** One SVG path for all the segments of a retained object. This bounds native nodes for grids and profiles. */
5
+ export declare function DrawingShape({ geometry, selected, ink, surface, precision, locale }: {
6
+ geometry: DrawingGeometry;
7
+ selected: boolean;
8
+ ink: string;
9
+ surface: string;
10
+ locale?: string;
11
+ precision: number;
12
+ }): React.JSX.Element;
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { DrawingStore, type Drawing, type DrawingPoint, type DrawingType, type EngineFrame } from '@supersolutions/super-chart-core';
3
+ export interface NativeDrawingProps {
4
+ readonly locale?: string;
5
+ readonly precision?: number;
6
+ readonly drawingStore?: DrawingStore;
7
+ /** Snap a placed anchor or an edited handle within 10 points of a candle OHLC. Defaults to true. */
8
+ readonly drawingMagnet?: boolean;
9
+ readonly drawingTool?: DrawingType | null;
10
+ /** Provide the user's content for a text or image tool before placement. */
11
+ readonly drawingText?: string;
12
+ readonly drawingImage?: string;
13
+ /** The core store accepts #rrggbb and #rrggbbaa for retained objects. */
14
+ readonly drawingColor?: string;
15
+ readonly onDrawingComplete?: (drawing: Drawing) => void;
16
+ readonly onDrawingError?: (error: Error) => void;
17
+ readonly onDrawingProgress?: (placed: number, total: number | null) => void;
18
+ }
19
+ export declare function useDrawingInteraction(frame: EngineFrame | null, props: NativeDrawingProps, ink: string, surface: string): {
20
+ nodes: React.JSX.Element;
21
+ tap: (p: DrawingPoint) => boolean;
22
+ begin: (p: DrawingPoint) => boolean;
23
+ move: (p: DrawingPoint) => void;
24
+ end: (p: DrawingPoint) => void;
25
+ cancel: () => void;
26
+ finishPath: () => void;
27
+ regions: {
28
+ line: boolean;
29
+ x1: number;
30
+ x2: number;
31
+ y1: number;
32
+ y2: number;
33
+ tolerance: number;
34
+ }[];
35
+ editingHandle: () => boolean;
36
+ };
@@ -0,0 +1,66 @@
1
+ import { type DrawingPoint, type EngineFrame, type Viewport } from '@supersolutions/super-chart-core';
2
+ export type InteractionMode = 'chart' | 'scroll' | 'none';
3
+ type Layers = {
4
+ begin: (point: DrawingPoint) => boolean;
5
+ cancel: () => void;
6
+ end: (point: DrawingPoint) => void;
7
+ finishPath: () => void;
8
+ move: (point: DrawingPoint) => void;
9
+ tap: (point: DrawingPoint) => boolean;
10
+ };
11
+ interface Options {
12
+ frame: EngineFrame | null;
13
+ mode: InteractionMode;
14
+ drawing: boolean;
15
+ layers: Layers;
16
+ inspect: (point: DrawingPoint | null) => void;
17
+ changeViewport: (viewport: Viewport) => void;
18
+ reset: () => void;
19
+ aim?: (point: DrawingPoint | null, lifted?: boolean) => DrawingPoint | null;
20
+ onPress?: (point: DrawingPoint, frame: EngineFrame) => void;
21
+ }
22
+ type Touch = {
23
+ locationX: number;
24
+ locationY: number;
25
+ };
26
+ export interface ChartTouchEvent {
27
+ readonly nativeEvent: Touch & {
28
+ readonly touches: readonly Touch[];
29
+ readonly changedTouches: readonly Touch[];
30
+ };
31
+ }
32
+ /** One full-size native hit surface supplies plot-local coordinates for every finger. */
33
+ export declare function useChartGestures(options: Options): {
34
+ cancel: () => void;
35
+ pinchAt: (a: DrawingPoint, b: DrawingPoint, view?: Viewport) => void;
36
+ captured: () => boolean;
37
+ nativePan: () => void;
38
+ handlers: {
39
+ onStartShouldSetResponder: (e: ChartTouchEvent) => boolean;
40
+ onMoveShouldSetResponder: (e: ChartTouchEvent) => boolean;
41
+ onResponderTerminationRequest: () => boolean;
42
+ onResponderTerminate: () => void;
43
+ onTouchCancel: () => void;
44
+ onTouchStart: (e: ChartTouchEvent) => void;
45
+ onTouchMove: (e: ChartTouchEvent) => void;
46
+ onTouchEnd: (e: ChartTouchEvent) => void;
47
+ };
48
+ };
49
+ /** Gesture state belongs to a single mounted surface. Events always read the latest frame and layer callbacks. */
50
+ export declare function createChartGestures(options: () => Options): {
51
+ cancel: () => void;
52
+ pinchAt: (a: DrawingPoint, b: DrawingPoint, view?: Viewport) => void;
53
+ captured: () => boolean;
54
+ nativePan: () => void;
55
+ handlers: {
56
+ onStartShouldSetResponder: (e: ChartTouchEvent) => boolean;
57
+ onMoveShouldSetResponder: (e: ChartTouchEvent) => boolean;
58
+ onResponderTerminationRequest: () => boolean;
59
+ onResponderTerminate: () => void;
60
+ onTouchCancel: () => void;
61
+ onTouchStart: (e: ChartTouchEvent) => void;
62
+ onTouchMove: (e: ChartTouchEvent) => void;
63
+ onTouchEnd: (e: ChartTouchEvent) => void;
64
+ };
65
+ };
66
+ export {};
@@ -0,0 +1,7 @@
1
+ export { SuperChart } from './SuperChart';
2
+ export type { SuperChartProps, SuperChartHandle } from './SuperChart';
3
+ export { LIGHT_THEME, DARK_THEME } from './model';
4
+ export type { ChartTheme, NativeChartMode } from './model';
5
+ export type { InteractionMode } from './gestures';
6
+ export type { NativeAnnotation, NativeChartMarker, NativeDrawingProps, NativeLayerProps } from './overlays';
7
+ export type { MarketBar, EngineFrame, EngineIndicatorSpec, IndicatorDefinition, Drawing, DrawingType } from '@supersolutions/super-chart-core';