@@ -7,12 +7,7 @@ import { useSharedValue } from "react-native-reanimated";
77import { AxisLabelComponentProps , AxisLabelContainer } from "./AxisLabel" ;
88import { Cursor } from "./Cursor" ;
99import { computePath , type ComputePathProps , computeGraphData } from "./computations" ;
10- import {
11- DEFAULT_CURSOR_RADIUS ,
12- DEFAULT_CURVE_TYPE ,
13- DEFAULT_FORMATTER ,
14- DEFAULT_STROKE_WIDTH ,
15- } from "./constants" ;
10+ import { DEFAULT_CURSOR_RADIUS , DEFAULT_CURVE_TYPE , DEFAULT_STROKE_WIDTH } from "./constants" ;
1611import {
1712 HoverGestureHandlerOnBeginEventPayload ,
1813 HoverGestureHandlerOnChangeEventPayload ,
@@ -23,16 +18,22 @@ import {
2318 useGestures ,
2419} from "./useGestures" ;
2520
21+ export interface PathFillProps {
22+ strokeWidth : number ;
23+ height : number ;
24+ width : number ;
25+ }
26+
2627export type LineChartProps = ViewProps & {
2728 /** Array of [x, y] points for the chart */
2829 points : [ number , number ] [ ] ;
2930 strokeWidth ?: number ;
3031 cursorRadius ?: number ;
3132 curveType ?: ComputePathProps [ "curveType" ] ;
3233 /** A worklet function to format a given price. */
33- formatter ?: ( price : number ) => string ;
3434 TopAxisLabel ?: React . FC < AxisLabelComponentProps > ;
3535 BottomAxisLabel ?: React . FC < AxisLabelComponentProps > ;
36+ PathFill ?: React . FC < PathFillProps > ;
3637 /** Callback when the pan gesture begins. This function must be a worklet function. */
3738 onPanGestureBegin ?: ( ( payload : PanGestureHandlerOnBeginEventPayload ) => void ) | null ;
3839 onPanGestureChange ?: ( ( payload : PanGestureHandlerOnChangeEventPayload ) => void ) | null ;
@@ -47,9 +48,9 @@ export const LineChart: React.FC<LineChartProps> = ({
4748 strokeWidth = DEFAULT_STROKE_WIDTH ,
4849 cursorRadius = DEFAULT_CURSOR_RADIUS ,
4950 curveType = DEFAULT_CURVE_TYPE ,
50- formatter = DEFAULT_FORMATTER ,
5151 TopAxisLabel = null ,
5252 BottomAxisLabel = null ,
53+ PathFill = null ,
5354 onPanGestureBegin = null ,
5455 onPanGestureChange = null ,
5556 onPanGestureEnd = null ,
@@ -104,7 +105,9 @@ export const LineChart: React.FC<LineChartProps> = ({
104105 < GestureDetector gesture = { gestures } >
105106 < View style = { styles . container } onLayout = { onLayout } >
106107 < Canvas style = { { height, width } } >
107- < Path style = "stroke" path = { path } strokeWidth = { strokeWidth } color = "black" />
108+ < Path style = "stroke" path = { path } strokeWidth = { strokeWidth } color = "white" >
109+ { PathFill && PathFill ( { width, height, strokeWidth } ) }
110+ </ Path >
108111 < Cursor x = { x } y = { y } height = { height } cursorRadius = { cursorRadius } />
109112 </ Canvas >
110113 </ View >
0 commit comments