import { useDerivedValue, withSpring } from 'react-native-reanimated'; import { useChart } from '../LineChartContext'; import { BlurMask, Circle, Group, Line, LinearGradient, vec, } from '@shopify/react-native-skia'; export interface IProps { crosshairColor?: string; circleColor?: string; } export type LineChartCursorPropsInterface = IProps; /** * The Crosshair and Highlight Circle */ const ChartCursor: React.FC = ({ crosshairColor = 'white', circleColor = 'white', }) => { const { currentX, currentY, isActive, padding, height, gradientPositions } = useChart(); // Calculate line endpoints responsively using Reanimated derived values const lineP1 = useDerivedValue(() => vec(currentX.value, padding)); const lineP2 = useDerivedValue(() => vec(currentX.value, height - padding)); const opacity = useDerivedValue(() => withSpring(isActive.value ? 1 : 0)); const defaultColors = ['#00E396', '#00E396', '#EA3943', '#EA3943']; const gradientColorsHalo = [ '#00E396E6', '#00E39600', '#EA394300', '#EA394326', ]; return ( {/* BlurMask gives the line a subtle glow/shadow effect */} {/* Outer Glow Halo */} {/* Inner Color Dot */} {/* White Border Ring */} ); }; export default ChartCursor;