UNPKG

victory-native

Version:

A charting library for React Native with a focus on performance and customization.

68 lines (67 loc) 2.56 kB
import * as React from "react"; import { type Color, type PathProps, type SkPath } from "@shopify/react-native-skia"; import type { ChartBounds, PointsArray } from "../../types"; import { type CandlestickGeometry, type CandlestickStatus } from "../utils/getCandlestickGeometry"; export type CandlestickColors = { positive?: Color; negative?: Color; neutral?: Color; }; export type CandlestickBodyPathOptions = Partial<Pick<PathProps, "color" | "blendMode" | "opacity" | "antiAlias">> & { children?: React.ReactNode; }; export type CandlestickWickPathOptions = Partial<Pick<PathProps, "color" | "blendMode" | "opacity" | "antiAlias" | "strokeWidth" | "strokeCap">> & { children?: React.ReactNode; }; export type CandlestickOptions = { body?: CandlestickBodyPathOptions; wick?: CandlestickWickPathOptions; }; export type CandlestickOptionsContext = CandlestickGeometry & { isPositive: boolean; isNegative: boolean; isNeutral: boolean; }; export type CandlestickOptionsFn = (context: CandlestickOptionsContext) => CandlestickOptions; export type CandlestickPathGroup = { key: string; status: CandlestickStatus; bodyPath: SkPath; wickPath: SkPath; bodyOptions: Required<Pick<CandlestickBodyPathOptions, "color">>; wickOptions: Required<Pick<CandlestickWickPathOptions, "color" | "strokeWidth">>; }; export type CustomCandlestickPath = { key: string; geometry: CandlestickGeometry; bodyPath: SkPath; wickPath: SkPath; bodyOptions: CandlestickBodyPathOptions; wickOptions: CandlestickWickPathOptions; }; export type UseCandlestickPathsResult = { mode: "grouped"; candleWidth: number; geometry: CandlestickGeometry[]; groups: CandlestickPathGroup[]; } | { mode: "custom"; candleWidth: number; geometry: CandlestickGeometry[]; candles: CustomCandlestickPath[]; }; export type UseCandlestickPathsArgs = { openPoints: PointsArray; highPoints: PointsArray; lowPoints: PointsArray; closePoints: PointsArray; chartBounds: ChartBounds; candleWidth?: number; candleRatio?: number; candleCount?: number; minBodyHeight?: number; candleColors?: CandlestickColors; wickStrokeWidth?: number; candleOptions?: CandlestickOptionsFn; }; export declare const useCandlestickPaths: ({ openPoints, highPoints, lowPoints, closePoints, chartBounds, candleWidth: customCandleWidth, candleRatio, candleCount, minBodyHeight, candleColors, wickStrokeWidth, candleOptions, }: UseCandlestickPathsArgs) => UseCandlestickPathsResult;