react-native-wagmi-charts 2.3.0 → 2.3.2
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 +23 -22
- package/lib/commonjs/charts/candle/Candle.js +6 -19
- package/lib/commonjs/charts/candle/Candle.js.map +1 -1
- package/lib/commonjs/charts/candle/Candles.js +6 -13
- package/lib/commonjs/charts/candle/Candles.js.map +1 -1
- package/lib/commonjs/charts/candle/Chart.js +3 -12
- package/lib/commonjs/charts/candle/Chart.js.map +1 -1
- package/lib/commonjs/charts/candle/Context.js +4 -12
- package/lib/commonjs/charts/candle/Context.js.map +1 -1
- package/lib/commonjs/charts/candle/Crosshair.js +3 -18
- package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
- package/lib/commonjs/charts/candle/CrosshairTooltip.js +6 -21
- package/lib/commonjs/charts/candle/CrosshairTooltip.js.map +1 -1
- package/lib/commonjs/charts/candle/DatetimeText.js +2 -8
- package/lib/commonjs/charts/candle/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/candle/HoverTrap/index.web.js +12 -24
- package/lib/commonjs/charts/candle/HoverTrap/index.web.js.map +1 -1
- package/lib/commonjs/charts/candle/Line.js +3 -12
- package/lib/commonjs/charts/candle/Line.js.map +1 -1
- package/lib/commonjs/charts/candle/PriceText.js +2 -8
- package/lib/commonjs/charts/candle/PriceText.js.map +1 -1
- package/lib/commonjs/charts/candle/index.js +1 -32
- package/lib/commonjs/charts/candle/index.js.map +1 -1
- package/lib/commonjs/charts/candle/types.js.map +1 -1
- package/lib/commonjs/charts/candle/useCandleData.js +0 -4
- package/lib/commonjs/charts/candle/useCandleData.js.map +1 -1
- package/lib/commonjs/charts/candle/useCandlestickChart.js +2 -7
- package/lib/commonjs/charts/candle/useCandlestickChart.js.map +1 -1
- package/lib/commonjs/charts/candle/useDatetime.js +0 -4
- package/lib/commonjs/charts/candle/useDatetime.js.map +1 -1
- package/lib/commonjs/charts/candle/usePrice.js +0 -8
- package/lib/commonjs/charts/candle/usePrice.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getDomain.js +0 -1
- package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getHeight.js +0 -2
- package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getPrice.js +0 -2
- package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/getY.js +0 -2
- package/lib/commonjs/charts/candle/utils/getY.js.map +1 -1
- package/lib/commonjs/charts/candle/utils/index.js +0 -8
- package/lib/commonjs/charts/candle/utils/index.js.map +1 -1
- package/lib/commonjs/charts/candle/utils.js +1 -6
- package/lib/commonjs/charts/candle/utils.js.map +1 -1
- package/lib/commonjs/charts/line/Chart.js +9 -28
- package/lib/commonjs/charts/line/Chart.js.map +1 -1
- package/lib/commonjs/charts/line/ChartPath.js +23 -46
- package/lib/commonjs/charts/line/ChartPath.js.map +1 -1
- package/lib/commonjs/charts/line/Context.js +8 -19
- package/lib/commonjs/charts/line/Context.js.map +1 -1
- package/lib/commonjs/charts/line/Cursor.js +41 -66
- package/lib/commonjs/charts/line/Cursor.js.map +1 -1
- package/lib/commonjs/charts/line/CursorCrosshair.js +5 -14
- package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/commonjs/charts/line/CursorLine.js +5 -19
- package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
- package/lib/commonjs/charts/line/Data.js +5 -17
- package/lib/commonjs/charts/line/Data.js.map +1 -1
- package/lib/commonjs/charts/line/DatetimeText.js +2 -9
- package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/line/Dot.js +27 -33
- package/lib/commonjs/charts/line/Dot.js.map +1 -1
- package/lib/commonjs/charts/line/Gradient.js +12 -19
- package/lib/commonjs/charts/line/Gradient.js.map +1 -1
- package/lib/commonjs/charts/line/Group.js +2 -14
- package/lib/commonjs/charts/line/Group.js.map +1 -1
- package/lib/commonjs/charts/line/Highlight.js +9 -21
- package/lib/commonjs/charts/line/Highlight.js.map +1 -1
- package/lib/commonjs/charts/line/HorizontalLine.js +8 -23
- package/lib/commonjs/charts/line/HorizontalLine.js.map +1 -1
- package/lib/commonjs/charts/line/HoverTrap/index.js +0 -4
- package/lib/commonjs/charts/line/HoverTrap/index.js.map +1 -1
- package/lib/commonjs/charts/line/HoverTrap/index.web.js +12 -23
- package/lib/commonjs/charts/line/HoverTrap/index.web.js.map +1 -1
- package/lib/commonjs/charts/line/LineChartPathContext.js +1 -6
- package/lib/commonjs/charts/line/LineChartPathContext.js.map +1 -1
- package/lib/commonjs/charts/line/Path.js +9 -18
- package/lib/commonjs/charts/line/Path.js.map +1 -1
- package/lib/commonjs/charts/line/PriceText.js +2 -9
- package/lib/commonjs/charts/line/PriceText.js.map +1 -1
- package/lib/commonjs/charts/line/Tooltip.js +25 -47
- package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
- package/lib/commonjs/charts/line/index.js +1 -39
- package/lib/commonjs/charts/line/index.js.map +1 -1
- package/lib/commonjs/charts/line/types.js.map +1 -1
- package/lib/commonjs/charts/line/useAnimatedPath.js +6 -12
- package/lib/commonjs/charts/line/useAnimatedPath.js.map +1 -1
- package/lib/commonjs/charts/line/useCurrentY.js +0 -7
- package/lib/commonjs/charts/line/useCurrentY.js.map +1 -1
- package/lib/commonjs/charts/line/useDatetime.js +0 -4
- package/lib/commonjs/charts/line/useDatetime.js.map +1 -1
- package/lib/commonjs/charts/line/useLineChart.js +4 -10
- package/lib/commonjs/charts/line/useLineChart.js.map +1 -1
- package/lib/commonjs/charts/line/usePrice.js +1 -5
- package/lib/commonjs/charts/line/usePrice.js.map +1 -1
- package/lib/commonjs/charts/line/utils/getArea.js +11 -11
- package/lib/commonjs/charts/line/utils/getArea.js.map +1 -1
- package/lib/commonjs/charts/line/utils/getDomain.js +0 -1
- package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -1
- package/lib/commonjs/charts/line/utils/getPath.js +5 -8
- package/lib/commonjs/charts/line/utils/getPath.js.map +1 -1
- package/lib/commonjs/charts/line/utils/getXPositionForCurve.js +15 -0
- package/lib/commonjs/charts/line/utils/getXPositionForCurve.js.map +1 -0
- package/lib/commonjs/charts/line/utils/index.js +0 -10
- package/lib/commonjs/charts/line/utils/index.js.map +1 -1
- package/lib/commonjs/charts/line/utils/interpolatePath.js +119 -124
- package/lib/commonjs/charts/line/utils/interpolatePath.js.map +1 -1
- package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +0 -3
- package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js.map +1 -1
- package/lib/commonjs/components/AnimatedText.js +6 -17
- package/lib/commonjs/components/AnimatedText.js.map +1 -1
- package/lib/commonjs/index.js +0 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/formatDatetime.js +0 -1
- package/lib/commonjs/utils/formatDatetime.js.map +1 -1
- package/lib/commonjs/utils/formatPrice.js +2 -12
- package/lib/commonjs/utils/formatPrice.js.map +1 -1
- package/lib/commonjs/utils/index.js +0 -6
- package/lib/commonjs/utils/index.js.map +1 -1
- package/lib/commonjs/utils/usePrevious.js +4 -9
- package/lib/commonjs/utils/usePrevious.js.map +1 -1
- package/lib/module/charts/candle/Candle.js +4 -2
- package/lib/module/charts/candle/Candle.js.map +1 -1
- package/lib/module/charts/candle/Candles.js +4 -3
- package/lib/module/charts/candle/Candles.js.map +1 -1
- package/lib/module/charts/candle/Chart.js.map +1 -1
- package/lib/module/charts/candle/Context.js.map +1 -1
- package/lib/module/charts/candle/Crosshair.js +1 -4
- package/lib/module/charts/candle/Crosshair.js.map +1 -1
- package/lib/module/charts/candle/CrosshairTooltip.js +3 -6
- package/lib/module/charts/candle/CrosshairTooltip.js.map +1 -1
- package/lib/module/charts/candle/DatetimeText.js.map +1 -1
- package/lib/module/charts/candle/HoverTrap/index.web.js +12 -14
- package/lib/module/charts/candle/HoverTrap/index.web.js.map +1 -1
- package/lib/module/charts/candle/Line.js +1 -2
- package/lib/module/charts/candle/Line.js.map +1 -1
- package/lib/module/charts/candle/PriceText.js.map +1 -1
- package/lib/module/charts/candle/index.js.map +1 -1
- package/lib/module/charts/candle/types.js.map +1 -1
- package/lib/module/charts/candle/useCandleData.js +0 -1
- package/lib/module/charts/candle/useCandleData.js.map +1 -1
- package/lib/module/charts/candle/useCandlestickChart.js.map +1 -1
- package/lib/module/charts/candle/useDatetime.js.map +1 -1
- package/lib/module/charts/candle/usePrice.js +0 -2
- package/lib/module/charts/candle/usePrice.js.map +1 -1
- package/lib/module/charts/candle/utils/getDomain.js.map +1 -1
- package/lib/module/charts/candle/utils/getHeight.js.map +1 -1
- package/lib/module/charts/candle/utils/getPrice.js.map +1 -1
- package/lib/module/charts/candle/utils/getY.js.map +1 -1
- package/lib/module/charts/candle/utils/index.js.map +1 -1
- package/lib/module/charts/candle/utils.js.map +1 -1
- package/lib/module/charts/line/Chart.js +8 -12
- package/lib/module/charts/line/Chart.js.map +1 -1
- package/lib/module/charts/line/ChartPath.js +21 -28
- package/lib/module/charts/line/ChartPath.js.map +1 -1
- package/lib/module/charts/line/Context.js +4 -6
- package/lib/module/charts/line/Context.js.map +1 -1
- package/lib/module/charts/line/Cursor.js +37 -50
- package/lib/module/charts/line/Cursor.js.map +1 -1
- package/lib/module/charts/line/CursorCrosshair.js +3 -3
- package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/module/charts/line/CursorLine.js +3 -3
- package/lib/module/charts/line/CursorLine.js.map +1 -1
- package/lib/module/charts/line/Data.js +0 -2
- package/lib/module/charts/line/Data.js.map +1 -1
- package/lib/module/charts/line/DatetimeText.js.map +1 -1
- package/lib/module/charts/line/Dot.js +25 -18
- package/lib/module/charts/line/Dot.js.map +1 -1
- package/lib/module/charts/line/Gradient.js +10 -5
- package/lib/module/charts/line/Gradient.js.map +1 -1
- package/lib/module/charts/line/Group.js +0 -2
- package/lib/module/charts/line/Group.js.map +1 -1
- package/lib/module/charts/line/Highlight.js +7 -5
- package/lib/module/charts/line/Highlight.js.map +1 -1
- package/lib/module/charts/line/HorizontalLine.js +6 -8
- package/lib/module/charts/line/HorizontalLine.js.map +1 -1
- package/lib/module/charts/line/HoverTrap/index.js.map +1 -1
- package/lib/module/charts/line/HoverTrap/index.web.js +12 -14
- package/lib/module/charts/line/HoverTrap/index.web.js.map +1 -1
- package/lib/module/charts/line/LineChartPathContext.js.map +1 -1
- package/lib/module/charts/line/Path.js +7 -4
- package/lib/module/charts/line/Path.js.map +1 -1
- package/lib/module/charts/line/PriceText.js.map +1 -1
- package/lib/module/charts/line/Tooltip.js +21 -33
- package/lib/module/charts/line/Tooltip.js.map +1 -1
- package/lib/module/charts/line/index.js.map +1 -1
- package/lib/module/charts/line/types.js.map +1 -1
- package/lib/module/charts/line/useAnimatedPath.js +3 -5
- package/lib/module/charts/line/useAnimatedPath.js.map +1 -1
- package/lib/module/charts/line/useCurrentY.js +0 -1
- package/lib/module/charts/line/useCurrentY.js.map +1 -1
- package/lib/module/charts/line/useDatetime.js.map +1 -1
- package/lib/module/charts/line/useLineChart.js +2 -1
- package/lib/module/charts/line/useLineChart.js.map +1 -1
- package/lib/module/charts/line/usePrice.js +1 -1
- package/lib/module/charts/line/usePrice.js.map +1 -1
- package/lib/module/charts/line/utils/getArea.js +9 -6
- package/lib/module/charts/line/utils/getArea.js.map +1 -1
- package/lib/module/charts/line/utils/getDomain.js.map +1 -1
- package/lib/module/charts/line/utils/getPath.js +3 -3
- package/lib/module/charts/line/utils/getPath.js.map +1 -1
- package/lib/module/charts/line/utils/getXPositionForCurve.js +9 -0
- package/lib/module/charts/line/utils/getXPositionForCurve.js.map +1 -0
- package/lib/module/charts/line/utils/index.js.map +1 -1
- package/lib/module/charts/line/utils/interpolatePath.js +116 -117
- package/lib/module/charts/line/utils/interpolatePath.js.map +1 -1
- package/lib/module/charts/line/utils/lineChartDataPropToArray.js +0 -2
- package/lib/module/charts/line/utils/lineChartDataPropToArray.js.map +1 -1
- package/lib/module/components/AnimatedText.js +4 -3
- package/lib/module/components/AnimatedText.js.map +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/formatDatetime.js.map +1 -1
- package/lib/module/utils/formatPrice.js +2 -11
- package/lib/module/utils/formatPrice.js.map +1 -1
- package/lib/module/utils/index.js.map +1 -1
- package/lib/module/utils/usePrevious.js +2 -3
- package/lib/module/utils/usePrevious.js.map +1 -1
- package/lib/typescript/src/charts/candle/Candle.d.ts +7 -5
- package/lib/typescript/src/charts/candle/Candle.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/Candles.d.ts +4 -3
- package/lib/typescript/src/charts/candle/Candles.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/Chart.d.ts +3 -2
- package/lib/typescript/src/charts/candle/Chart.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/Context.d.ts +3 -2
- package/lib/typescript/src/charts/candle/Context.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/Crosshair.d.ts +3 -2
- package/lib/typescript/src/charts/candle/Crosshair.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts +4 -3
- package/lib/typescript/src/charts/candle/CrosshairTooltip.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/DatetimeText.d.ts +4 -3
- package/lib/typescript/src/charts/candle/DatetimeText.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/HoverTrap/index.web.d.ts +3 -2
- package/lib/typescript/src/charts/candle/HoverTrap/index.web.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/Line.d.ts +4 -3
- package/lib/typescript/src/charts/candle/Line.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/PriceText.d.ts +4 -3
- package/lib/typescript/src/charts/candle/PriceText.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/index.d.ts +3 -2
- package/lib/typescript/src/charts/candle/index.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/types.d.ts +7 -6
- package/lib/typescript/src/charts/candle/types.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/useCandleData.d.ts +1 -0
- package/lib/typescript/src/charts/candle/useCandleData.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +1 -0
- package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/useDatetime.d.ts +1 -0
- package/lib/typescript/src/charts/candle/useDatetime.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/usePrice.d.ts +1 -0
- package/lib/typescript/src/charts/candle/usePrice.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +1 -0
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +1 -0
- package/lib/typescript/src/charts/candle/utils/getHeight.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +1 -0
- package/lib/typescript/src/charts/candle/utils/getPrice.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/utils/getY.d.ts +1 -0
- package/lib/typescript/src/charts/candle/utils/getY.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/utils/index.d.ts +1 -0
- package/lib/typescript/src/charts/candle/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/charts/candle/utils.d.ts +1 -0
- package/lib/typescript/src/charts/candle/utils.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Chart.d.ts +3 -2
- package/lib/typescript/src/charts/line/Chart.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/ChartPath.d.ts +3 -2
- package/lib/typescript/src/charts/line/ChartPath.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Context.d.ts +3 -2
- package/lib/typescript/src/charts/line/Context.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Cursor.d.ts +3 -2
- package/lib/typescript/src/charts/line/Cursor.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +3 -2
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/CursorLine.d.ts +3 -2
- package/lib/typescript/src/charts/line/CursorLine.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Data.d.ts +6 -4
- package/lib/typescript/src/charts/line/Data.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/DatetimeText.d.ts +4 -3
- package/lib/typescript/src/charts/line/DatetimeText.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Dot.d.ts +4 -3
- package/lib/typescript/src/charts/line/Dot.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Gradient.d.ts +3 -2
- package/lib/typescript/src/charts/line/Gradient.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Group.d.ts +4 -2
- package/lib/typescript/src/charts/line/Group.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Highlight.d.ts +4 -3
- package/lib/typescript/src/charts/line/Highlight.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/HorizontalLine.d.ts +4 -3
- package/lib/typescript/src/charts/line/HorizontalLine.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/HoverTrap/index.d.ts +3 -2
- package/lib/typescript/src/charts/line/HoverTrap/index.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts +3 -2
- package/lib/typescript/src/charts/line/HoverTrap/index.web.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/LineChartPathContext.d.ts +1 -0
- package/lib/typescript/src/charts/line/LineChartPathContext.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Path.d.ts +4 -3
- package/lib/typescript/src/charts/line/Path.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/PriceText.d.ts +4 -3
- package/lib/typescript/src/charts/line/PriceText.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/Tooltip.d.ts +4 -3
- package/lib/typescript/src/charts/line/Tooltip.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/index.d.ts +2 -1
- package/lib/typescript/src/charts/line/index.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/types.d.ts +8 -7
- package/lib/typescript/src/charts/line/types.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +1 -0
- package/lib/typescript/src/charts/line/useAnimatedPath.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/useCurrentY.d.ts +1 -0
- package/lib/typescript/src/charts/line/useCurrentY.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/useDatetime.d.ts +1 -0
- package/lib/typescript/src/charts/line/useDatetime.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/useLineChart.d.ts +1 -0
- package/lib/typescript/src/charts/line/useLineChart.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/usePrice.d.ts +1 -0
- package/lib/typescript/src/charts/line/usePrice.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/utils/getArea.d.ts +3 -1
- package/lib/typescript/src/charts/line/utils/getArea.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts +1 -0
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/utils/getPath.d.ts +1 -0
- package/lib/typescript/src/charts/line/utils/getPath.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts +3 -0
- package/lib/typescript/src/charts/line/utils/getXPositionForCurve.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/utils/index.d.ts +1 -0
- package/lib/typescript/src/charts/line/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts +1 -0
- package/lib/typescript/src/charts/line/utils/interpolatePath.d.ts.map +1 -0
- package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +1 -0
- package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts.map +1 -0
- package/lib/typescript/src/components/AnimatedText.d.ts +3 -2
- package/lib/typescript/src/components/AnimatedText.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/formatDatetime.d.ts +1 -0
- package/lib/typescript/src/utils/formatDatetime.d.ts.map +1 -0
- package/lib/typescript/src/utils/formatPrice.d.ts +1 -0
- package/lib/typescript/src/utils/formatPrice.d.ts.map +1 -0
- package/lib/typescript/src/utils/index.d.ts +1 -0
- package/lib/typescript/src/utils/index.d.ts.map +1 -0
- package/lib/typescript/src/utils/usePrevious.d.ts +1 -0
- package/lib/typescript/src/utils/usePrevious.d.ts.map +1 -0
- package/package.json +10 -9
- package/src/charts/candle/Candle.tsx +3 -3
- package/src/charts/candle/CrosshairTooltip.tsx +2 -2
- package/src/charts/line/Chart.tsx +6 -4
- package/src/charts/line/Cursor.tsx +52 -67
- package/src/charts/line/Dot.tsx +8 -8
- package/src/charts/line/Gradient.tsx +1 -0
- package/src/charts/line/HorizontalLine.tsx +8 -15
- package/src/charts/line/Tooltip.tsx +21 -13
- package/src/charts/line/useAnimatedPath.ts +3 -3
- package/src/charts/line/utils/getArea.ts +8 -5
- package/src/charts/line/utils/getXPositionForCurve.ts +9 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCurrentY.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/useCurrentY.ts"],"names":[],"mappings":"AAMA,wBAAgB,WAAW;;GAc1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDatetime.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/useDatetime.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EACN,MAAM,EACN,OAAO,GACR,GAAE;IACD,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;CACjC;;;;;;;EA4BL"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLineChart.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/useLineChart.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY;;;;;;;;;;;;;;;;;;EAY3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrice.d.ts","sourceRoot":"","sources":["../../../../../src/charts/line/usePrice.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,SAAa,EACb,KAAK,GACN,GAAE;IAAE,MAAM,CAAC,EAAE,YAAY,CAAC,MAAM,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO;;;;;;;EAuB5E"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { TLineChartData, YDomain } from '../types';
|
|
2
|
-
export declare function getArea({ data, width, height, gutter, shape: _shape, yDomain, }: {
|
|
2
|
+
export declare function getArea({ data, width, height, gutter, shape: _shape, yDomain, xDomain, }: {
|
|
3
3
|
data: TLineChartData;
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
6
|
gutter: number;
|
|
7
7
|
shape?: unknown;
|
|
8
8
|
yDomain: YDomain;
|
|
9
|
+
xDomain?: [number, number];
|
|
9
10
|
}): string;
|
|
11
|
+
//# sourceMappingURL=getArea.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getArea.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/getArea.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxD,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EAAE,MAAM,EACb,OAAO,EACP,OAAO,GACR,EAAE;IACD,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,GAAG,MAAM,CAgBT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getDomain.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/getDomain.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,wBAAgB,SAAS,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAInE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getPath.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/getPath.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAExD,wBAAgB,OAAO,CAAC,EACtB,IAAI,EACJ,IAAI,EACJ,EAAE,EACF,KAAK,EACL,MAAM,EACN,MAAM,EACN,KAAK,EAAE,MAAM,EACb,OAAO,EACP,OAAO,GACR,EAAE;IACD,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC5B,GAAG,MAAM,CAsBT"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getXPositionForCurve.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/getXPositionForCurve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,UAM7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC"}
|
|
@@ -48,3 +48,4 @@ export declare function interpolatePathCommands(aCommandsInput: any, bCommandsIn
|
|
|
48
48
|
* @returns {Function} Interpolation function that maps t ([0, 1]) to a path `d` string.
|
|
49
49
|
*/
|
|
50
50
|
export declare function interpolatePath(a: any, b: any, excludeSegment: any): (t: any) => any;
|
|
51
|
+
//# sourceMappingURL=interpolatePath.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpolatePath.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/interpolatePath.ts"],"names":[],"mappings":"AA6IA;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,YAAY,KAAA,EAAE,UAAU,KAAA,EAAE,YAAY,KAAA,QAahE;AA8QD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,KAAA;;IAiCvC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,uBAAuB,CACrC,cAAc,KAAA,EACd,cAAc,KAAA,EACd,cAAc,KAAA,mBAsGf;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,CAAC,KAAA,EAAE,CAAC,KAAA,EAAE,cAAc,KAAA,mBAuCnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lineChartDataPropToArray.d.ts","sourceRoot":"","sources":["../../../../../../src/charts/line/utils/lineChartDataPropToArray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnE,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,kBAAkB,GAC3B,cAAc,CAoBhB"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { TextProps as RNTextProps } from 'react-native';
|
|
3
3
|
import Animated from 'react-native-reanimated';
|
|
4
4
|
interface AnimatedTextProps {
|
|
5
5
|
text: Animated.SharedValue<string>;
|
|
6
6
|
style?: Animated.AnimateProps<RNTextProps>['style'];
|
|
7
7
|
}
|
|
8
|
-
export declare const AnimatedText: ({ text, style }: AnimatedTextProps) => JSX.Element;
|
|
8
|
+
export declare const AnimatedText: ({ text, style }: AnimatedTextProps) => React.JSX.Element;
|
|
9
9
|
export {};
|
|
10
|
+
//# sourceMappingURL=AnimatedText.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnimatedText.d.ts","sourceRoot":"","sources":["../../../../src/components/AnimatedText.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAwB,SAAS,IAAI,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9E,OAAO,QAGN,MAAM,yBAAyB,CAAC;AAIjC,UAAU,iBAAiB;IACzB,IAAI,EAAE,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC;CACrD;AAID,eAAO,MAAM,YAAY,oBAAqB,iBAAiB,sBAuC9D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatDatetime.d.ts","sourceRoot":"","sources":["../../../../src/utils/formatDatetime.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,MAAgB,EAChB,OAAY,GACb,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC;CACtC,UAIA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatPrice.d.ts","sourceRoot":"","sources":["../../../../src/utils/formatPrice.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EAAE,MAAM,EACb,YAAY,EAAE,aAAkB,EAChC,SAAS,GACV,EAAE;IACD,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,UA4BA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrevious.d.ts","sourceRoot":"","sources":["../../../../src/utils/usePrevious.ts"],"names":[],"mappings":"AAEA,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,iBAUtC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-wagmi-charts",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
4
4
|
"description": "A sweet candlestick chart for React Native",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -39,17 +39,18 @@
|
|
|
39
39
|
"d3-interpolate-path": "^2.2.3",
|
|
40
40
|
"d3-scale": "^2",
|
|
41
41
|
"d3-shape": "^3.0.1",
|
|
42
|
+
"d3-array": "^3.1.6",
|
|
42
43
|
"react-keyed-flatten-children": "^1.3.0",
|
|
43
44
|
"react-native-redash": "^16.1.1"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@commitlint/config-conventional": "^12.0.4",
|
|
47
48
|
"@react-native-community/eslint-config": "^3.0.0",
|
|
48
|
-
"@types/d3-array": "^3.0.
|
|
49
|
+
"@types/d3-array": "^3.0.5",
|
|
49
50
|
"@types/d3-scale": "^4.0.3",
|
|
50
51
|
"@types/jest": "^26.0.24",
|
|
51
|
-
"@types/react": "^
|
|
52
|
-
"@types/react-native": "^0.
|
|
52
|
+
"@types/react": "^18.2.45",
|
|
53
|
+
"@types/react-native": "^0.72.8",
|
|
53
54
|
"eslint": "^7.31.0",
|
|
54
55
|
"eslint-config-prettier": "^8.3.0",
|
|
55
56
|
"eslint-plugin-prettier": "^3.4.0",
|
|
@@ -58,13 +59,13 @@
|
|
|
58
59
|
"jest": "^27.0.6",
|
|
59
60
|
"pod-install": "^0.1.24",
|
|
60
61
|
"prettier": "^2.3.2",
|
|
61
|
-
"react": "
|
|
62
|
-
"react-native": "0.
|
|
63
|
-
"react-native-builder-bob": "^0.
|
|
62
|
+
"react": "^18.2.0",
|
|
63
|
+
"react-native": "^0.72.8",
|
|
64
|
+
"react-native-builder-bob": "^0.23.2",
|
|
64
65
|
"react-native-gesture-handler": "^2.1.0",
|
|
65
|
-
"react-native-reanimated": "~
|
|
66
|
+
"react-native-reanimated": "~3.3.0",
|
|
66
67
|
"react-native-svg": "^12.1.1",
|
|
67
|
-
"typescript": "^
|
|
68
|
+
"typescript": "^5.3.3"
|
|
68
69
|
},
|
|
69
70
|
"peerDependencies": {
|
|
70
71
|
"react": "*",
|
|
@@ -4,7 +4,6 @@ import Animated, {
|
|
|
4
4
|
useAnimatedProps,
|
|
5
5
|
} from 'react-native-reanimated';
|
|
6
6
|
import {
|
|
7
|
-
Color,
|
|
8
7
|
Line,
|
|
9
8
|
LineProps,
|
|
10
9
|
NumberProp,
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
|
|
15
14
|
import type { TCandle, TDomain } from './types';
|
|
16
15
|
import { getY, getHeight } from './utils';
|
|
16
|
+
import { ColorValue } from 'react-native';
|
|
17
17
|
|
|
18
18
|
const AnimatedRect = Animated.createAnimatedComponent(Rect);
|
|
19
19
|
const AnimatedLine = Animated.createAnimatedComponent(Line);
|
|
@@ -41,7 +41,7 @@ export type CandlestickChartCandleProps = {
|
|
|
41
41
|
y: NumberProp;
|
|
42
42
|
width: NumberProp;
|
|
43
43
|
height: NumberProp;
|
|
44
|
-
fill:
|
|
44
|
+
fill: ColorValue;
|
|
45
45
|
useAnimations: boolean;
|
|
46
46
|
}) => React.ReactNode;
|
|
47
47
|
renderLine?: ({
|
|
@@ -56,7 +56,7 @@ export type CandlestickChartCandleProps = {
|
|
|
56
56
|
y1: NumberProp;
|
|
57
57
|
x2: NumberProp;
|
|
58
58
|
y2: NumberProp;
|
|
59
|
-
stroke:
|
|
59
|
+
stroke: ColorValue;
|
|
60
60
|
strokeWidth: NumberProp;
|
|
61
61
|
useAnimations: boolean;
|
|
62
62
|
}) => React.ReactNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type { StyleProp, TextStyle, ViewProps } from 'react-native';
|
|
2
|
+
import type { LayoutChangeEvent, StyleProp, TextStyle, ViewProps } from 'react-native';
|
|
3
3
|
import { StyleSheet } from 'react-native';
|
|
4
4
|
import Animated, {
|
|
5
5
|
useAnimatedStyle,
|
|
@@ -49,7 +49,7 @@ export function CandlestickChartCrosshairTooltip({
|
|
|
49
49
|
const elementWidth = useSharedValue(0);
|
|
50
50
|
|
|
51
51
|
const handleLayout = React.useCallback(
|
|
52
|
-
(event) => {
|
|
52
|
+
(event: LayoutChangeEvent) => {
|
|
53
53
|
elementHeight.value = event.nativeEvent.layout.height;
|
|
54
54
|
elementWidth.value = event.nativeEvent.layout.width;
|
|
55
55
|
},
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
// @ts-ignore
|
|
3
3
|
import * as d3Shape from 'd3-shape';
|
|
4
|
+
|
|
4
5
|
import { Dimensions, StyleSheet, View, ViewProps } from 'react-native';
|
|
5
|
-
import { LineChartContext } from './Context';
|
|
6
6
|
import { LineChartIdProvider, useLineChartData } from './Data';
|
|
7
|
-
|
|
7
|
+
import { Path, parse } from 'react-native-redash';
|
|
8
8
|
import { getArea, getPath } from './utils';
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
import { LineChartContext } from './Context';
|
|
10
11
|
|
|
11
12
|
export const LineChartDimensionsContext = React.createContext({
|
|
12
13
|
width: 0,
|
|
@@ -84,10 +85,11 @@ export function LineChart({
|
|
|
84
85
|
gutter: yGutter,
|
|
85
86
|
shape,
|
|
86
87
|
yDomain,
|
|
88
|
+
xDomain,
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
91
|
return '';
|
|
90
|
-
}, [data, pathWidth, height, yGutter, shape, yDomain]);
|
|
92
|
+
}, [data, pathWidth, height, yGutter, shape, yDomain, xDomain]);
|
|
91
93
|
|
|
92
94
|
const dataLength = data.length;
|
|
93
95
|
const parsedPath = React.useMemo(() => parse(path), [path]);
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import Animated, {
|
|
4
|
+
runOnJS,
|
|
5
|
+
useAnimatedGestureHandler,
|
|
6
|
+
} from 'react-native-reanimated';
|
|
3
7
|
import {
|
|
4
8
|
GestureEvent,
|
|
5
9
|
LongPressGestureHandler,
|
|
6
10
|
LongPressGestureHandlerEventPayload,
|
|
7
11
|
LongPressGestureHandlerProps,
|
|
8
12
|
} from 'react-native-gesture-handler';
|
|
9
|
-
import Animated, {
|
|
10
|
-
runOnJS,
|
|
11
|
-
useAnimatedGestureHandler,
|
|
12
|
-
} from 'react-native-reanimated';
|
|
13
13
|
|
|
14
14
|
import { LineChartDimensionsContext } from './Chart';
|
|
15
|
-
import {
|
|
16
|
-
import { scaleLinear } from 'd3-scale';
|
|
15
|
+
import { StyleSheet } from 'react-native';
|
|
17
16
|
import { bisectCenter } from 'd3-array';
|
|
18
|
-
import
|
|
17
|
+
import { scaleLinear } from 'd3-scale';
|
|
18
|
+
import { useLineChart } from './useLineChart';
|
|
19
19
|
|
|
20
20
|
export type LineChartCursorProps = LongPressGestureHandlerProps & {
|
|
21
21
|
children: React.ReactNode;
|
|
22
22
|
type: 'line' | 'crosshair';
|
|
23
|
+
// Does not work on web due to how the Cursor operates on web
|
|
23
24
|
snapToPoint?: boolean;
|
|
24
25
|
};
|
|
25
26
|
|
|
@@ -27,50 +28,6 @@ export const CursorContext = React.createContext({ type: '' });
|
|
|
27
28
|
|
|
28
29
|
LineChartCursor.displayName = 'LineChartCursor';
|
|
29
30
|
|
|
30
|
-
const linearScalePositionAndIndex = ({
|
|
31
|
-
timestamps,
|
|
32
|
-
width,
|
|
33
|
-
xToUpdate,
|
|
34
|
-
currentIndex,
|
|
35
|
-
xPosition,
|
|
36
|
-
path,
|
|
37
|
-
xDomain,
|
|
38
|
-
}: {
|
|
39
|
-
timestamps: number[];
|
|
40
|
-
width: number;
|
|
41
|
-
xToUpdate: Animated.SharedValue<number>;
|
|
42
|
-
currentIndex: Animated.SharedValue<number>;
|
|
43
|
-
xPosition: number;
|
|
44
|
-
path: Path | undefined;
|
|
45
|
-
xDomain: [number, number] | undefined;
|
|
46
|
-
}) => {
|
|
47
|
-
if (!path) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const domainArray = xDomain ?? [0, timestamps.length];
|
|
52
|
-
|
|
53
|
-
// Same scale as in /src/charts/line/utils/getPath.ts
|
|
54
|
-
const scaleX = scaleLinear().domain(domainArray).range([0, width]);
|
|
55
|
-
|
|
56
|
-
// Calculate a scaled timestamp for the current touch position
|
|
57
|
-
const xRelative = scaleX.invert(xPosition);
|
|
58
|
-
|
|
59
|
-
const closestIndex = bisectCenter(timestamps, xRelative);
|
|
60
|
-
const pathDataDelta = Math.abs(path.curves.length - timestamps.length); // sometimes there is a difference between data length and number of path curves.
|
|
61
|
-
const closestPathCurve = Math.max(
|
|
62
|
-
Math.min(bisectCenter(timestamps, xRelative), path.curves.length + 1) -
|
|
63
|
-
pathDataDelta,
|
|
64
|
-
0
|
|
65
|
-
);
|
|
66
|
-
|
|
67
|
-
const p0 = (closestIndex > 0 ? path.curves[closestPathCurve].to : path.move)
|
|
68
|
-
.x;
|
|
69
|
-
// Update values
|
|
70
|
-
currentIndex.value = closestIndex;
|
|
71
|
-
xToUpdate.value = p0;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
31
|
export function LineChartCursor({
|
|
75
32
|
children,
|
|
76
33
|
snapToPoint,
|
|
@@ -81,17 +38,53 @@ export function LineChartCursor({
|
|
|
81
38
|
LineChartDimensionsContext
|
|
82
39
|
);
|
|
83
40
|
const { currentX, currentIndex, isActive, data, xDomain } = useLineChart();
|
|
41
|
+
const xValues = React.useMemo(
|
|
42
|
+
() => data.map(({ timestamp }, i) => (xDomain ? timestamp : i)),
|
|
43
|
+
[data, xDomain]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
// Same scale as in /src/charts/line/utils/getPath.ts
|
|
47
|
+
const scaleX = React.useMemo(() => {
|
|
48
|
+
const domainArray = xDomain ?? [0, xValues.length];
|
|
49
|
+
return scaleLinear().domain(domainArray).range([0, width]);
|
|
50
|
+
}, [width, xDomain, xValues.length]);
|
|
51
|
+
|
|
52
|
+
const linearScalePositionAndIndex = ({
|
|
53
|
+
xPosition,
|
|
54
|
+
}: {
|
|
55
|
+
xPosition: number;
|
|
56
|
+
}) => {
|
|
57
|
+
if (!parsedPath) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Calculate a scaled timestamp for the current touch position
|
|
62
|
+
const xRelative = scaleX.invert(xPosition);
|
|
63
|
+
|
|
64
|
+
const closestIndex = bisectCenter(xValues, xRelative);
|
|
65
|
+
const pathDataDelta = Math.abs(parsedPath.curves.length - xValues.length); // sometimes there is a difference between data length and number of path curves.
|
|
66
|
+
const closestPathCurve = Math.max(
|
|
67
|
+
Math.min(closestIndex, parsedPath.curves.length + 1) - pathDataDelta,
|
|
68
|
+
0
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
const newXPosition = (
|
|
72
|
+
closestIndex > 0
|
|
73
|
+
? parsedPath.curves[closestPathCurve].to
|
|
74
|
+
: parsedPath.move
|
|
75
|
+
).x;
|
|
76
|
+
// Update values
|
|
77
|
+
currentIndex.value = closestIndex;
|
|
78
|
+
currentX.value = newXPosition;
|
|
79
|
+
};
|
|
84
80
|
|
|
85
81
|
const onGestureEvent = useAnimatedGestureHandler<
|
|
86
82
|
GestureEvent<LongPressGestureHandlerEventPayload>
|
|
87
83
|
>({
|
|
88
84
|
onActive: ({ x }) => {
|
|
89
85
|
if (parsedPath) {
|
|
90
|
-
const
|
|
86
|
+
const xPosition = Math.max(0, x <= width ? x : width);
|
|
91
87
|
isActive.value = true;
|
|
92
|
-
const xValues = data.map(({ timestamp }, i) =>
|
|
93
|
-
xDomain ? timestamp : i
|
|
94
|
-
);
|
|
95
88
|
|
|
96
89
|
// on Web, we could drag the cursor to be negative, breaking it
|
|
97
90
|
// so we clamp the index at 0 to fix it
|
|
@@ -99,22 +92,14 @@ export function LineChartCursor({
|
|
|
99
92
|
const minIndex = 0;
|
|
100
93
|
const boundedIndex = Math.max(
|
|
101
94
|
minIndex,
|
|
102
|
-
Math.round(
|
|
95
|
+
Math.round(xPosition / width / (1 / (data.length - 1)))
|
|
103
96
|
);
|
|
104
97
|
|
|
105
98
|
if (snapToPoint) {
|
|
106
99
|
// We have to run this on the JS thread unfortunately as the scaleLinear functions won't work on UI thread
|
|
107
|
-
runOnJS(linearScalePositionAndIndex)({
|
|
108
|
-
timestamps: xValues,
|
|
109
|
-
width,
|
|
110
|
-
xToUpdate: currentX,
|
|
111
|
-
currentIndex,
|
|
112
|
-
xPosition: boundedX,
|
|
113
|
-
path: parsedPath,
|
|
114
|
-
xDomain,
|
|
115
|
-
});
|
|
100
|
+
runOnJS(linearScalePositionAndIndex)({ xPosition });
|
|
116
101
|
} else if (!snapToPoint) {
|
|
117
|
-
currentX.value =
|
|
102
|
+
currentX.value = xPosition;
|
|
118
103
|
currentIndex.value = boundedIndex;
|
|
119
104
|
}
|
|
120
105
|
}
|
package/src/charts/line/Dot.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
|
|
2
3
|
import Animated, {
|
|
3
4
|
Easing,
|
|
4
5
|
useAnimatedProps,
|
|
@@ -8,10 +9,11 @@ import Animated, {
|
|
|
8
9
|
withTiming,
|
|
9
10
|
} from 'react-native-reanimated';
|
|
10
11
|
import { Circle, CircleProps } from 'react-native-svg';
|
|
11
|
-
import { getYForX } from 'react-native-redash';
|
|
12
12
|
|
|
13
13
|
import { LineChartDimensionsContext } from './Chart';
|
|
14
14
|
import { LineChartPathContext } from './LineChartPathContext';
|
|
15
|
+
import { getXPositionForCurve } from './utils/getXPositionForCurve';
|
|
16
|
+
import { getYForX } from 'react-native-redash';
|
|
15
17
|
import { useLineChart } from './useLineChart';
|
|
16
18
|
|
|
17
19
|
const AnimatedCircle = Animated.createAnimatedComponent(Circle);
|
|
@@ -58,9 +60,7 @@ export function LineChartDot({
|
|
|
58
60
|
outerSize = size * 4,
|
|
59
61
|
}: LineChartDotProps) {
|
|
60
62
|
const { isActive } = useLineChart();
|
|
61
|
-
const { parsedPath
|
|
62
|
-
LineChartDimensionsContext
|
|
63
|
-
);
|
|
63
|
+
const { parsedPath } = React.useContext(LineChartDimensionsContext);
|
|
64
64
|
|
|
65
65
|
////////////////////////////////////////////////////////////
|
|
66
66
|
|
|
@@ -72,10 +72,10 @@ export function LineChartDot({
|
|
|
72
72
|
|
|
73
73
|
////////////////////////////////////////////////////////////
|
|
74
74
|
|
|
75
|
-
const x = useDerivedValue(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const x = useDerivedValue(() => {
|
|
76
|
+
return withTiming(getXPositionForCurve(parsedPath, at));
|
|
77
|
+
}, [at, parsedPath]);
|
|
78
|
+
|
|
79
79
|
const y = useDerivedValue(
|
|
80
80
|
() => withTiming(getYForX(parsedPath!, x.value) || 0),
|
|
81
81
|
[parsedPath, x]
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import Animated, {
|
|
3
2
|
useAnimatedProps,
|
|
4
3
|
useDerivedValue,
|
|
5
4
|
withTiming,
|
|
6
5
|
} from 'react-native-reanimated';
|
|
7
|
-
import { Line as SVGLine
|
|
8
|
-
import { getYForX } from 'react-native-redash';
|
|
6
|
+
import { LineProps, Line as SVGLine } from 'react-native-svg';
|
|
9
7
|
|
|
10
8
|
import { LineChartDimensionsContext } from './Chart';
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { getXPositionForCurve } from './utils/getXPositionForCurve';
|
|
11
|
+
import { getYForX } from 'react-native-redash';
|
|
11
12
|
import { useLineChart } from './useLineChart';
|
|
12
13
|
|
|
13
14
|
const AnimatedLine = Animated.createAnimatedComponent(SVGLine);
|
|
@@ -53,7 +54,7 @@ export function LineChartHorizontalLine({
|
|
|
53
54
|
at = { index: 0 },
|
|
54
55
|
offsetY = 0,
|
|
55
56
|
}: HorizontalLineProps) {
|
|
56
|
-
const { width, parsedPath,
|
|
57
|
+
const { width, parsedPath, height, gutter } = React.useContext(
|
|
57
58
|
LineChartDimensionsContext
|
|
58
59
|
);
|
|
59
60
|
const { yDomain } = useLineChart();
|
|
@@ -61,7 +62,8 @@ export function LineChartHorizontalLine({
|
|
|
61
62
|
const y = useDerivedValue(() => {
|
|
62
63
|
if (typeof at === 'number' || at.index != null) {
|
|
63
64
|
const index = typeof at === 'number' ? at : at.index;
|
|
64
|
-
const yForX =
|
|
65
|
+
const yForX =
|
|
66
|
+
getYForX(parsedPath!, getXPositionForCurve(parsedPath, index)) || 0;
|
|
65
67
|
return withTiming(yForX + offsetY);
|
|
66
68
|
}
|
|
67
69
|
/**
|
|
@@ -82,16 +84,7 @@ export function LineChartHorizontalLine({
|
|
|
82
84
|
const offsetTopPixels = gutter + percentageOffsetTop * heightBetweenGutters;
|
|
83
85
|
|
|
84
86
|
return withTiming(offsetTopPixels + offsetY);
|
|
85
|
-
}, [
|
|
86
|
-
at,
|
|
87
|
-
gutter,
|
|
88
|
-
height,
|
|
89
|
-
offsetY,
|
|
90
|
-
parsedPath,
|
|
91
|
-
pointWidth,
|
|
92
|
-
yDomain.max,
|
|
93
|
-
yDomain.min,
|
|
94
|
-
]);
|
|
87
|
+
}, [at, gutter, height, offsetY, parsedPath, yDomain.max, yDomain.min]);
|
|
95
88
|
|
|
96
89
|
const lineAnimatedProps = useAnimatedProps(
|
|
97
90
|
() => ({
|