react-native-wagmi-charts 1.0.4 → 1.2.1
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/.DS_Store +0 -0
- package/.prettierrc.js +5 -0
- package/README.md +171 -121
- package/example/.DS_Store +0 -0
- package/example/README.md +32 -0
- package/example/package.json +1 -1
- package/example/src/App.tsx +32 -7
- package/example/src/CandlestickChart.tsx +23 -11
- package/example/src/LineChart.tsx +51 -20
- package/example/src/{candlestick-data.json → data/candlestick-data.json} +0 -0
- package/example/src/{candlestick-data2.json → data/candlestick-data2.json} +0 -0
- package/example/src/{line-data.json → data/line-data.json} +0 -0
- package/example/src/{line-data2.json → data/line-data2.json} +0 -0
- package/example/yarn.lock +5 -5
- package/lib/commonjs/charts/candle/Crosshair.js +6 -17
- package/lib/commonjs/charts/candle/Crosshair.js.map +1 -1
- package/lib/commonjs/charts/candle/CrosshairTooltip.js +12 -8
- package/lib/commonjs/charts/candle/CrosshairTooltip.js.map +1 -1
- package/lib/commonjs/charts/candle/DatetimeText.js +7 -8
- package/lib/commonjs/charts/candle/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/candle/Line.js.map +1 -1
- package/lib/commonjs/charts/candle/PriceText.js +7 -8
- package/lib/commonjs/charts/candle/PriceText.js.map +1 -1
- package/lib/commonjs/charts/candle/useCandleData.js.map +1 -1
- package/lib/commonjs/charts/candle/useCandlestickChart.js.map +1 -1
- package/lib/commonjs/charts/candle/useDatetime.js.map +1 -1
- package/lib/commonjs/charts/candle/usePrice.js.map +1 -1
- package/lib/commonjs/charts/candle/utils.js.map +1 -1
- package/lib/commonjs/charts/line/Chart.js.map +1 -1
- package/lib/commonjs/charts/line/Cursor.js.map +1 -1
- package/lib/commonjs/charts/line/CursorCrosshair.js +4 -3
- package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/commonjs/charts/line/CursorLine.js +8 -1
- package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
- package/lib/commonjs/charts/line/DatetimeText.js +7 -8
- package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/line/Path.js +13 -16
- package/lib/commonjs/charts/line/Path.js.map +1 -1
- package/lib/commonjs/charts/line/PriceText.js +7 -8
- package/lib/commonjs/charts/line/PriceText.js.map +1 -1
- package/lib/commonjs/charts/line/interpolatePath.js +600 -0
- package/lib/commonjs/charts/line/interpolatePath.js.map +1 -0
- package/lib/commonjs/charts/line/useDatetime.js.map +1 -1
- package/lib/commonjs/charts/line/usePrice.js.map +1 -1
- package/lib/commonjs/charts/line/utils.js +1 -70
- package/lib/commonjs/charts/line/utils.js.map +1 -1
- package/lib/commonjs/components/AnimatedText.js +63 -0
- package/lib/commonjs/components/AnimatedText.js.map +1 -0
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/module/charts/candle/Crosshair.js +7 -16
- package/lib/module/charts/candle/Crosshair.js.map +1 -1
- package/lib/module/charts/candle/CrosshairTooltip.js +10 -8
- package/lib/module/charts/candle/CrosshairTooltip.js.map +1 -1
- package/lib/module/charts/candle/DatetimeText.js +6 -7
- package/lib/module/charts/candle/DatetimeText.js.map +1 -1
- package/lib/module/charts/candle/Line.js.map +1 -1
- package/lib/module/charts/candle/PriceText.js +6 -7
- package/lib/module/charts/candle/PriceText.js.map +1 -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.map +1 -1
- package/lib/module/charts/candle/utils.js.map +1 -1
- package/lib/module/charts/line/Chart.js.map +1 -1
- package/lib/module/charts/line/Cursor.js.map +1 -1
- package/lib/module/charts/line/CursorCrosshair.js +4 -3
- package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/module/charts/line/CursorLine.js +7 -1
- package/lib/module/charts/line/CursorLine.js.map +1 -1
- package/lib/module/charts/line/DatetimeText.js +6 -7
- package/lib/module/charts/line/DatetimeText.js.map +1 -1
- package/lib/module/charts/line/Path.js +11 -15
- package/lib/module/charts/line/Path.js.map +1 -1
- package/lib/module/charts/line/PriceText.js +6 -7
- package/lib/module/charts/line/PriceText.js.map +1 -1
- package/lib/module/charts/line/interpolatePath.js +587 -0
- package/lib/module/charts/line/interpolatePath.js.map +1 -0
- package/lib/module/charts/line/useDatetime.js.map +1 -1
- package/lib/module/charts/line/usePrice.js.map +1 -1
- package/lib/module/charts/line/utils.js +1 -66
- package/lib/module/charts/line/utils.js.map +1 -1
- package/lib/module/components/AnimatedText.js +43 -0
- package/lib/module/components/AnimatedText.js.map +1 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/src/charts/candle/Crosshair.d.ts +4 -4
- package/lib/typescript/src/charts/candle/DatetimeText.d.ts +3 -2
- package/lib/typescript/src/charts/candle/Line.d.ts +1 -1
- package/lib/typescript/src/charts/candle/PriceText.d.ts +3 -3
- package/lib/typescript/src/charts/candle/types.d.ts +8 -3
- package/lib/typescript/src/charts/candle/useCandleData.d.ts +3 -3
- package/lib/typescript/src/charts/candle/useCandlestickChart.d.ts +2 -1
- package/lib/typescript/src/charts/candle/useDatetime.d.ts +5 -7
- package/lib/typescript/src/charts/candle/usePrice.d.ts +5 -8
- package/lib/typescript/src/charts/candle/utils.d.ts +1 -1
- package/lib/typescript/src/charts/line/Chart.d.ts +1 -1
- package/lib/typescript/src/charts/line/Cursor.d.ts +1 -2
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +3 -2
- package/lib/typescript/src/charts/line/DatetimeText.d.ts +5 -6
- package/lib/typescript/src/charts/line/Path.d.ts +17 -1
- package/lib/typescript/src/charts/line/PriceText.d.ts +3 -2
- package/lib/typescript/src/charts/line/interpolatePath.d.ts +50 -0
- package/lib/typescript/src/charts/line/useDatetime.d.ts +4 -5
- package/lib/typescript/src/charts/line/usePrice.d.ts +3 -2
- package/lib/typescript/src/charts/line/utils.d.ts +0 -13
- package/lib/typescript/src/components/AnimatedText.d.ts +9 -0
- package/lib/typescript/src/utils.d.ts +2 -4
- package/package.json +4 -4
- package/src/charts/candle/Crosshair.tsx +20 -20
- package/src/charts/candle/CrosshairTooltip.tsx +11 -4
- package/src/charts/candle/DatetimeText.tsx +5 -4
- package/src/charts/candle/Line.tsx +1 -1
- package/src/charts/candle/PriceText.tsx +5 -5
- package/src/charts/candle/types.ts +11 -3
- package/src/charts/candle/useCandleData.ts +3 -2
- package/src/charts/candle/useCandlestickChart.ts +2 -1
- package/src/charts/candle/useDatetime.ts +7 -3
- package/src/charts/candle/usePrice.ts +10 -3
- package/src/charts/candle/utils.ts +1 -1
- package/src/charts/line/Chart.tsx +1 -1
- package/src/charts/line/Cursor.tsx +7 -3
- package/src/charts/line/CursorCrosshair.tsx +4 -3
- package/src/charts/line/CursorLine.tsx +9 -1
- package/src/charts/line/DatetimeText.tsx +8 -7
- package/src/charts/line/Path.tsx +25 -21
- package/src/charts/line/PriceText.tsx +5 -4
- package/src/charts/line/interpolatePath.ts +650 -0
- package/src/charts/line/useDatetime.ts +3 -2
- package/src/charts/line/usePrice.ts +2 -1
- package/src/charts/line/utils.ts +2 -79
- package/src/components/AnimatedText.tsx +53 -0
- package/src/utils.ts +3 -3
- package/yarn.lock +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Cursor.tsx"],"names":["React","StyleSheet","LongPressGestureHandler","Animated","useAnimatedGestureHandler","getYForX","parse","LineChartDimensionsContext","useLineChart","CursorContext","createContext","type","LineChartCursor","children","props","width","path","useContext","currentX","currentY","currentIndex","isActive","data","parsedPath","useMemo","undefined","onGestureEvent","onActive","x","boundedX","value","Math","round","length","onEnd","absoluteFill"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,
|
|
1
|
+
{"version":3,"sources":["Cursor.tsx"],"names":["React","StyleSheet","LongPressGestureHandler","Animated","useAnimatedGestureHandler","getYForX","parse","LineChartDimensionsContext","useLineChart","CursorContext","createContext","type","LineChartCursor","children","props","width","path","useContext","currentX","currentY","currentIndex","isActive","data","parsedPath","useMemo","undefined","onGestureEvent","onActive","x","boundedX","value","Math","round","length","onEnd","absoluteFill"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,SAEEC,uBAFF,QAKO,8BALP;AAMA,OAAOC,QAAP,IAAmBC,yBAAnB,QAAoD,yBAApD;AACA,SAASC,QAAT,EAAmBC,KAAnB,QAAgC,qBAAhC;AAEA,SAASC,0BAAT,QAA2C,SAA3C;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAOA,OAAO,MAAMC,aAAa,gBAAGT,KAAK,CAACU,aAAN,CAAoB;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAApB,CAAtB;AAEP,OAAO,SAASC,eAAT,CAAyB;AAC9BC,EAAAA,QAD8B;AAE9BF,EAAAA,IAF8B;AAG9B,KAAGG;AAH2B,CAAzB,EAIkB;AACvB,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAkBhB,KAAK,CAACiB,UAAN,CAAiBV,0BAAjB,CAAxB;AACA,QAAM;AAAEW,IAAAA,QAAF;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA,YAAtB;AAAoCC,IAAAA,QAApC;AAA8CC,IAAAA;AAA9C,MAAuDd,YAAY,EAAzE;AAEA,QAAMe,UAAU,GAAGvB,KAAK,CAACwB,OAAN,CACjB,MAAOR,IAAI,GAAGV,KAAK,CAACU,IAAD,CAAR,GAAiBS,SADX,EAEjB,CAACT,IAAD,CAFiB,CAAnB;AAKA,QAAMU,cAAc,GAAGtB,yBAAyB,CAE9C;AACAuB,IAAAA,QAAQ,EAAE,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAAW;AACnB,UAAIL,UAAJ,EAAgB;AACd,cAAMM,QAAQ,GAAGD,CAAC,IAAIb,KAAL,GAAaa,CAAb,GAAiBb,KAAlC;AACAM,QAAAA,QAAQ,CAACS,KAAT,GAAiB,IAAjB;AACAZ,QAAAA,QAAQ,CAACY,KAAT,GAAiBD,QAAjB;AACAV,QAAAA,QAAQ,CAACW,KAAT,GAAiBzB,QAAQ,CAACkB,UAAD,EAAaM,QAAb,CAAR,IAAkC,CAAnD;AACAT,QAAAA,YAAY,CAACU,KAAb,GAAqBC,IAAI,CAACC,KAAL,CACnBH,QAAQ,GAAGd,KAAX,IAAoB,KAAKO,IAAI,CAACW,MAAL,GAAc,CAAnB,CAApB,CADmB,CAArB;AAGD;AACF,KAXD;AAYAC,IAAAA,KAAK,EAAE,MAAM;AACXb,MAAAA,QAAQ,CAACS,KAAT,GAAiB,KAAjB;AACAV,MAAAA,YAAY,CAACU,KAAb,GAAqB,CAAC,CAAtB;AACD;AAfD,GAF8C,CAAhD;AAoBA,sBACE,oBAAC,aAAD,CAAe,QAAf;AAAwB,IAAA,KAAK,EAAE;AAAEnB,MAAAA;AAAF;AAA/B,kBACE,oBAAC,uBAAD;AACE,IAAA,aAAa,EAAE,CADjB;AAEE,IAAA,cAAc,EAAEe;AAFlB,KAGMZ,KAHN,gBAKE,oBAAC,QAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEb,UAAU,CAACkC;AAAjC,KACGtB,QADH,CALF,CADF,CADF;AAaD","sourcesContent":["import * as React from 'react';\nimport { StyleSheet } from 'react-native';\nimport {\n GestureEvent,\n LongPressGestureHandler,\n LongPressGestureHandlerEventPayload,\n LongPressGestureHandlerProps,\n} from 'react-native-gesture-handler';\nimport Animated, { useAnimatedGestureHandler } from 'react-native-reanimated';\nimport { getYForX, parse } from 'react-native-redash';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { useLineChart } from './useLineChart';\n\nexport type LineChartCursorProps = LongPressGestureHandlerProps & {\n children: React.ReactNode;\n type: 'line' | 'crosshair';\n};\n\nexport const CursorContext = React.createContext({ type: '' });\n\nexport function LineChartCursor({\n children,\n type,\n ...props\n}: LineChartCursorProps) {\n const { width, path } = React.useContext(LineChartDimensionsContext);\n const { currentX, currentY, currentIndex, isActive, data } = useLineChart();\n\n const parsedPath = React.useMemo(\n () => (path ? parse(path) : undefined),\n [path]\n );\n\n const onGestureEvent = useAnimatedGestureHandler<\n GestureEvent<LongPressGestureHandlerEventPayload>\n >({\n onActive: ({ x }) => {\n if (parsedPath) {\n const boundedX = x <= width ? x : width;\n isActive.value = true;\n currentX.value = boundedX;\n currentY.value = getYForX(parsedPath, boundedX) || 0;\n currentIndex.value = Math.round(\n boundedX / width / (1 / (data.length - 1))\n );\n }\n },\n onEnd: () => {\n isActive.value = false;\n currentIndex.value = -1;\n },\n });\n\n return (\n <CursorContext.Provider value={{ type }}>\n <LongPressGestureHandler\n minDurationMs={0}\n onGestureEvent={onGestureEvent}\n {...props}\n >\n <Animated.View style={StyleSheet.absoluteFill}>\n {children}\n </Animated.View>\n </LongPressGestureHandler>\n </CursorContext.Provider>\n );\n}\n"]}
|
|
@@ -12,7 +12,8 @@ export function LineChartCursorCrosshair({
|
|
|
12
12
|
outerSize = 32,
|
|
13
13
|
crosshairWrapperProps = {},
|
|
14
14
|
crosshairProps = {},
|
|
15
|
-
crosshairOuterProps = {}
|
|
15
|
+
crosshairOuterProps = {},
|
|
16
|
+
...props
|
|
16
17
|
}) {
|
|
17
18
|
const {
|
|
18
19
|
currentX,
|
|
@@ -30,9 +31,9 @@ export function LineChartCursorCrosshair({
|
|
|
30
31
|
})
|
|
31
32
|
}]
|
|
32
33
|
}));
|
|
33
|
-
return /*#__PURE__*/React.createElement(LineChartCursor, {
|
|
34
|
+
return /*#__PURE__*/React.createElement(LineChartCursor, _extends({
|
|
34
35
|
type: "crosshair"
|
|
35
|
-
}, /*#__PURE__*/React.createElement(Animated.View, _extends({}, crosshairWrapperProps, {
|
|
36
|
+
}, props), /*#__PURE__*/React.createElement(Animated.View, _extends({}, crosshairWrapperProps, {
|
|
36
37
|
style: [{
|
|
37
38
|
width: outerSize,
|
|
38
39
|
height: outerSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CursorCrosshair.tsx"],"names":["React","View","Animated","useAnimatedStyle","withSpring","LineChartCursor","useLineChart","LineChartCursorCrosshair","children","color","size","outerSize","crosshairWrapperProps","crosshairProps","crosshairOuterProps","currentX","currentY","isActive","animatedCursorStyle","transform","translateX","value","translateY","scale","damping","width","height","alignItems","justifyContent","style","backgroundColor","borderRadius","opacity","position"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAgC,cAAhC;AACA,OAAOC,QAAP,IACEC,gBADF,EAEEC,UAFF,QAGO,yBAHP;AAKA,SAASC,eAAT,
|
|
1
|
+
{"version":3,"sources":["CursorCrosshair.tsx"],"names":["React","View","Animated","useAnimatedStyle","withSpring","LineChartCursor","useLineChart","LineChartCursorCrosshair","children","color","size","outerSize","crosshairWrapperProps","crosshairProps","crosshairOuterProps","props","currentX","currentY","isActive","animatedCursorStyle","transform","translateX","value","translateY","scale","damping","width","height","alignItems","justifyContent","style","backgroundColor","borderRadius","opacity","position"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,IAAT,QAAgC,cAAhC;AACA,OAAOC,QAAP,IACEC,gBADF,EAEEC,UAFF,QAGO,yBAHP;AAKA,SAASC,eAAT,QAAsD,UAAtD;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAYA,OAAO,SAASC,wBAAT,CAAkC;AACvCC,EAAAA,QADuC;AAEvCC,EAAAA,KAAK,GAAG,OAF+B;AAGvCC,EAAAA,IAAI,GAAG,CAHgC;AAIvCC,EAAAA,SAAS,GAAG,EAJ2B;AAKvCC,EAAAA,qBAAqB,GAAG,EALe;AAMvCC,EAAAA,cAAc,GAAG,EANsB;AAOvCC,EAAAA,mBAAmB,GAAG,EAPiB;AAQvC,KAAGC;AARoC,CAAlC,EAS2B;AAChC,QAAM;AAAEC,IAAAA,QAAF;AA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ADnB;AAEEiB,MAAAA,KAAK,EAAEhB,IAFT;AAGEiB,MAAAA,MAAM,EAAEjB,IAHV;AAIEsB,MAAAA,YAAY,EAAEtB;AAJhB,KADK,EAOLG,cAAc,CAACiB,KAPV;AAFT,KA3BF,CADF,EAyCGtB,QAzCH,CADF;AA6CD","sourcesContent":["import * as React from 'react';\nimport { View, ViewProps } from 'react-native';\nimport Animated, {\n useAnimatedStyle,\n withSpring,\n} from 'react-native-reanimated';\n\nimport { LineChartCursor, LineChartCursorProps } from './Cursor';\nimport { useLineChart } from './useLineChart';\n\ntype LineChartCursorCrosshairProps = Omit<LineChartCursorProps, 'type'> & {\n children?: React.ReactNode;\n color?: string;\n size?: number;\n outerSize?: number;\n crosshairWrapperProps?: Animated.AnimateProps<ViewProps>;\n crosshairProps?: ViewProps;\n crosshairOuterProps?: ViewProps;\n};\n\nexport function LineChartCursorCrosshair({\n children,\n color = 'black',\n size = 8,\n outerSize = 32,\n crosshairWrapperProps = {},\n crosshairProps = {},\n crosshairOuterProps = {},\n ...props\n}: LineChartCursorCrosshairProps) {\n const { currentX, currentY, isActive } = useLineChart();\n\n const animatedCursorStyle = useAnimatedStyle(() => ({\n transform: [\n { translateX: currentX.value - outerSize / 2 },\n { translateY: currentY.value - outerSize / 2 },\n {\n scale: withSpring(isActive.value ? 1 : 0, {\n damping: 10,\n }),\n },\n ],\n }));\n\n return (\n <LineChartCursor type=\"crosshair\" {...props}>\n <Animated.View\n {...crosshairWrapperProps}\n style={[\n {\n width: outerSize,\n height: outerSize,\n alignItems: 'center',\n justifyContent: 'center',\n },\n animatedCursorStyle,\n crosshairWrapperProps.style,\n ]}\n >\n <View\n {...crosshairOuterProps}\n style={[\n {\n backgroundColor: color,\n width: outerSize,\n height: outerSize,\n borderRadius: outerSize,\n opacity: 0.1,\n position: 'absolute',\n },\n crosshairOuterProps.style,\n ]}\n />\n <View\n {...crosshairProps}\n style={[\n {\n backgroundColor: color,\n width: size,\n height: size,\n borderRadius: size,\n },\n crosshairProps.style,\n ]}\n />\n </Animated.View>\n {children}\n </LineChartCursor>\n );\n}\n"]}
|
|
@@ -31,7 +31,7 @@ export const LineChartCursorLine = ({
|
|
|
31
31
|
}, /*#__PURE__*/React.createElement(Animated.View, {
|
|
32
32
|
style: vertical
|
|
33
33
|
}, /*#__PURE__*/React.createElement(Svg, {
|
|
34
|
-
style:
|
|
34
|
+
style: styles.svg
|
|
35
35
|
}, /*#__PURE__*/React.createElement(SVGLine, _extends({
|
|
36
36
|
x1: 0,
|
|
37
37
|
y1: 0,
|
|
@@ -42,4 +42,10 @@ export const LineChartCursorLine = ({
|
|
|
42
42
|
strokeDasharray: "3 3"
|
|
43
43
|
}, lineProps)))), children);
|
|
44
44
|
};
|
|
45
|
+
const styles = StyleSheet.create({
|
|
46
|
+
svg: { ...StyleSheet.absoluteFillObject,
|
|
47
|
+
// height: 100% is required for <svg /> on web
|
|
48
|
+
height: '100%'
|
|
49
|
+
}
|
|
50
|
+
});
|
|
45
51
|
//# sourceMappingURL=CursorLine.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CursorLine.tsx"],"names":["React","StyleSheet","Animated","useAnimatedStyle","Svg","Line","SVGLine","LineChartDimensionsContext","LineChartCursor","useLineChart","LineChartCursorLine","children","color","lineProps","height","useContext","currentX","isActive","vertical","opacity","value","transform","translateX","
|
|
1
|
+
{"version":3,"sources":["CursorLine.tsx"],"names":["React","StyleSheet","Animated","useAnimatedStyle","Svg","Line","SVGLine","LineChartDimensionsContext","LineChartCursor","useLineChart","LineChartCursorLine","children","color","lineProps","height","useContext","currentX","isActive","vertical","opacity","value","transform","translateX","styles","svg","create","absoluteFillObject"],"mappings":";;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,SAASC,UAAT,QAA2B,cAA3B;AACA,OAAOC,QAAP,IAAmBC,gBAAnB,QAA2C,yBAA3C;AACA,OAAOC,GAAP,IAAcC,IAAI,IAAIC,OAAtB,QAAgD,kBAAhD;AAEA,S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CAACyB,kBADX;AAEH;AACAZ,IAAAA,MAAM,EAAE;AAHL;AAD0B,CAAlB,CAAf","sourcesContent":["import React from 'react';\nimport { StyleSheet } from 'react-native';\nimport Animated, { useAnimatedStyle } from 'react-native-reanimated';\nimport Svg, { Line as SVGLine, LineProps } from 'react-native-svg';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { LineChartCursor } from './Cursor';\nimport { useLineChart } from './useLineChart';\n\ntype LineChartCursorLineProps = {\n children?: React.ReactNode;\n color?: string;\n lineProps?: Partial<LineProps>;\n};\n\nexport const LineChartCursorLine = ({\n children,\n color = 'gray',\n lineProps = {},\n}: LineChartCursorLineProps) => {\n const { height } = React.useContext(LineChartDimensionsContext);\n const { currentX, isActive } = useLineChart();\n\n const vertical = useAnimatedStyle(() => ({\n opacity: isActive.value ? 1 : 0,\n height: '100%',\n transform: [{ translateX: currentX.value }],\n }));\n\n return (\n <LineChartCursor type=\"line\">\n <Animated.View style={vertical}>\n <Svg style={styles.svg}>\n <SVGLine\n x1={0}\n y1={0}\n x2={0}\n y2={height}\n strokeWidth={2}\n stroke={color}\n strokeDasharray=\"3 3\"\n {...lineProps}\n />\n </Svg>\n </Animated.View>\n {children}\n </LineChartCursor>\n );\n};\n\nconst styles = StyleSheet.create({\n svg: {\n ...StyleSheet.absoluteFillObject,\n // height: 100% is required for <svg /> on web\n height: '100%',\n },\n});\n"]}
|
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
import { ReText } from 'react-native-redash';
|
|
5
2
|
import { useLineChartDatetime } from './useDatetime';
|
|
3
|
+
import { AnimatedText } from '../../components/AnimatedText';
|
|
6
4
|
export function LineChartDatetimeText({
|
|
7
5
|
locale,
|
|
8
6
|
options,
|
|
9
7
|
format,
|
|
10
8
|
variant = 'formatted',
|
|
11
|
-
|
|
9
|
+
style
|
|
12
10
|
}) {
|
|
13
11
|
const datetime = useLineChartDatetime({
|
|
14
12
|
format,
|
|
15
13
|
locale,
|
|
16
14
|
options
|
|
17
15
|
});
|
|
18
|
-
return /*#__PURE__*/React.createElement(
|
|
19
|
-
text: datetime[variant]
|
|
20
|
-
|
|
16
|
+
return /*#__PURE__*/React.createElement(AnimatedText, {
|
|
17
|
+
text: datetime[variant],
|
|
18
|
+
style: style
|
|
19
|
+
});
|
|
21
20
|
}
|
|
22
21
|
//# sourceMappingURL=DatetimeText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DatetimeText.tsx"],"names":["React","
|
|
1
|
+
{"version":3,"sources":["DatetimeText.tsx"],"names":["React","useLineChartDatetime","AnimatedText","LineChartDatetimeText","locale","options","format","variant","style","datetime"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAIA,SAASC,oBAAT,QAAqC,eAArC;AAEA,SAASC,YAAT,QAA6B,+BAA7B;AAUA,OAAO,SAASC,qBAAT,CAA+B;AACpCC,EAAAA,MADoC;AAEpCC,EAAAA,OAFoC;AAGpCC,EAAAA,MAHoC;AAIpCC,EAAAA,OAAO,GAAG,WAJ0B;AAKpCC,EAAAA;AALoC,CAA/B,EAMoB;AACzB,QAAMC,QAAQ,GAAGR,oBAAoB,CAAC;AAAEK,IAAAA,MAAF;AAAUF,IAAAA,MAAV;AAAkBC,IAAAA;AAAlB,GAAD,CAArC;AACA,sBAAO,oBAAC,YAAD;AAAc,IAAA,IAAI,EAAEI,QAAQ,CAACF,OAAD,CAA5B;AAAuC,IAAA,KAAK,EAAEC;AAA9C,IAAP;AACD","sourcesContent":["import * as React from 'react';\nimport type { TextProps as RNTextProps } from 'react-native';\nimport type Animated from 'react-native-reanimated';\n\nimport { useLineChartDatetime } from './useDatetime';\nimport type { TFormatterFn } from 'react-native-wagmi-charts';\nimport { AnimatedText } from '../../components/AnimatedText';\n\ntype LineChartDatetimeProps = {\n locale?: string;\n options?: Intl.DateTimeFormatOptions;\n format?: TFormatterFn<number>;\n variant?: 'formatted' | 'value';\n style?: Animated.AnimateProps<RNTextProps>['style'];\n};\n\nexport function LineChartDatetimeText({\n locale,\n options,\n format,\n variant = 'formatted',\n style,\n}: LineChartDatetimeProps) {\n const datetime = useLineChartDatetime({ format, locale, options });\n return <AnimatedText text={datetime[variant]} style={style} />;\n}\n"]}
|
|
@@ -3,15 +3,15 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import Animated, { useAnimatedProps, useAnimatedReaction, useSharedValue, withTiming } from 'react-native-reanimated';
|
|
5
5
|
import { Path } from 'react-native-svg';
|
|
6
|
-
import { mixPath, parse } from 'react-native-redash';
|
|
7
6
|
import { LineChartDimensionsContext } from './Chart';
|
|
7
|
+
import interpolatePath from './interpolatePath';
|
|
8
8
|
import { usePrevious } from '../../utils';
|
|
9
|
-
import { syncPaths } from './utils';
|
|
10
9
|
const AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
11
10
|
export function LineChartPath({
|
|
12
11
|
color = 'black',
|
|
13
12
|
width = 3,
|
|
14
13
|
isInactive,
|
|
14
|
+
isTransitionEnabled = true,
|
|
15
15
|
...props
|
|
16
16
|
}) {
|
|
17
17
|
const {
|
|
@@ -19,8 +19,7 @@ export function LineChartPath({
|
|
|
19
19
|
} = React.useContext(LineChartDimensionsContext); ////////////////////////////////////////////////
|
|
20
20
|
|
|
21
21
|
const transition = useSharedValue(0);
|
|
22
|
-
const
|
|
23
|
-
const previousParsedPath = usePrevious(parsedPath);
|
|
22
|
+
const previousPath = usePrevious(path);
|
|
24
23
|
useAnimatedReaction(() => {
|
|
25
24
|
return path;
|
|
26
25
|
}, (_, previous) => {
|
|
@@ -30,18 +29,15 @@ export function LineChartPath({
|
|
|
30
29
|
}
|
|
31
30
|
}, [path]);
|
|
32
31
|
const animatedProps = useAnimatedProps(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
parsedPath,
|
|
41
|
-
previousParsedPath
|
|
42
|
-
});
|
|
32
|
+
let d = path || '';
|
|
33
|
+
|
|
34
|
+
if (previousPath && isTransitionEnabled) {
|
|
35
|
+
const pathInterpolator = interpolatePath(previousPath, path, null);
|
|
36
|
+
d = pathInterpolator(transition.value);
|
|
37
|
+
}
|
|
38
|
+
|
|
43
39
|
return {
|
|
44
|
-
d
|
|
40
|
+
d
|
|
45
41
|
};
|
|
46
42
|
}); ////////////////////////////////////////////////
|
|
47
43
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Path.tsx"],"names":["React","Animated","useAnimatedProps","useAnimatedReaction","useSharedValue","withTiming","Path","
|
|
1
|
+
{"version":3,"sources":["Path.tsx"],"names":["React","Animated","useAnimatedProps","useAnimatedReaction","useSharedValue","withTiming","Path","LineChartDimensionsContext","interpolatePath","usePrevious","AnimatedPath","createAnimatedComponent","LineChartPath","color","width","isInactive","isTransitionEnabled","props","path","useContext","transition","previousPath","_","previous","value","animatedProps","d","pathInterpolator"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,OAAOC,QAAP,IACEC,gBADF,EAEEC,mBAFF,EAGEC,cAHF,EAIEC,UAJF,QAKO,yBALP;AAMA,SAASC,IAAT,QAAgC,kBAAhC;AAEA,SAASC,0BAAT,QAA2C,SAA3C;AACA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,SAASC,WAAT,QAA4B,aAA5B;AAEA,MAAMC,YAAY,GAAGT,QAAQ,CAACU,uBAAT,CAAiCL,IAAjC,CAArB;AAwBA,OAAO,SAASM,aAAT,CAAuB;AAC5BC,EAAAA,KAAK,GAAG,OADoB;AAE5BC,EAAAA,KAAK,GAAG,CAFoB;AAG5B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,\n useAnimatedReaction,\n useSharedValue,\n withTiming,\n} from 'react-native-reanimated';\nimport { Path, PathProps } from 'react-native-svg';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport interpolatePath from './interpolatePath';\nimport { usePrevious } from '../../utils';\n\nconst AnimatedPath = Animated.createAnimatedComponent(Path);\n\nexport type LineChartPathProps = Animated.AnimateProps<PathProps> & {\n color?: string;\n width?: number;\n isInactive?: boolean;\n /**\n * Default: `true`.\n *\n * If `false`, changes in the chart's path will not animate.\n *\n * While this use case is rare, it may be useful on web, where animations might not work as well.\n *\n * **Example**\n *\n * ```tsx\n * <LineChart.Path\n * pathProps={{ isTransitionEnabled: Platform.OS !== 'web' }}\n * />\n * ```\n */\n isTransitionEnabled?: boolean;\n};\n\nexport function LineChartPath({\n color = 'black',\n width = 3,\n isInactive,\n isTransitionEnabled = true,\n ...props\n}: LineChartPathProps) {\n const { path } = React.useContext(LineChartDimensionsContext);\n\n ////////////////////////////////////////////////\n\n const transition = useSharedValue(0);\n\n const previousPath = usePrevious(path);\n\n useAnimatedReaction(\n () => {\n return path;\n },\n (_, previous) => {\n if (previous) {\n transition.value = 0;\n transition.value = withTiming(1);\n }\n },\n [path]\n );\n\n const animatedProps = useAnimatedProps(() => {\n let d = path || '';\n if (previousPath && isTransitionEnabled) {\n const pathInterpolator = interpolatePath(previousPath, path, null);\n d = pathInterpolator(transition.value);\n }\n return {\n d,\n };\n });\n\n ////////////////////////////////////////////////\n\n return (\n <>\n <AnimatedPath\n animatedProps={animatedProps}\n fill=\"transparent\"\n stroke={color}\n strokeOpacity={isInactive ? 0.2 : 1}\n strokeWidth={width}\n {...props}\n />\n </>\n );\n}\n"]}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
-
|
|
3
1
|
import * as React from 'react';
|
|
4
|
-
import { ReText } from 'react-native-redash';
|
|
5
2
|
import { useLineChartPrice } from './usePrice';
|
|
3
|
+
import { AnimatedText } from '../../components/AnimatedText';
|
|
6
4
|
export function LineChartPriceText({
|
|
7
5
|
format,
|
|
8
6
|
precision = 2,
|
|
9
7
|
variant = 'formatted',
|
|
10
|
-
|
|
8
|
+
style
|
|
11
9
|
}) {
|
|
12
10
|
const price = useLineChartPrice({
|
|
13
11
|
format,
|
|
14
12
|
precision
|
|
15
13
|
});
|
|
16
|
-
return /*#__PURE__*/React.createElement(
|
|
17
|
-
text: price[variant]
|
|
18
|
-
|
|
14
|
+
return /*#__PURE__*/React.createElement(AnimatedText, {
|
|
15
|
+
text: price[variant],
|
|
16
|
+
style: style
|
|
17
|
+
});
|
|
19
18
|
}
|
|
20
19
|
//# sourceMappingURL=PriceText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["PriceText.tsx"],"names":["React","
|
|
1
|
+
{"version":3,"sources":["PriceText.tsx"],"names":["React","useLineChartPrice","AnimatedText","LineChartPriceText","format","precision","variant","style","price"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAIA,SAASC,iBAAT,QAAkC,YAAlC;AAEA,SAASC,YAAT,QAA6B,+BAA7B;AASA,OAAO,SAASC,kBAAT,CAA4B;AACjCC,EAAAA,MADiC;AAEjCC,EAAAA,SAAS,GAAG,CAFqB;AAGjCC,EAAAA,OAAO,GAAG,WAHuB;AAIjCC,EAAAA;AAJiC,CAA5B,EAKqB;AAC1B,QAAMC,KAAK,GAAGP,iBAAiB,CAAC;AAAEG,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAD,CAA/B;AACA,sBAAO,oBAAC,YAAD;AAAc,IAAA,IAAI,EAAEG,KAAK,CAACF,OAAD,CAAzB;AAAoC,IAAA,KAAK,EAAEC;AAA3C,IAAP;AACD","sourcesContent":["import * as React from 'react';\nimport type { TextProps as RNTextProps } from 'react-native';\nimport type Animated from 'react-native-reanimated';\n\nimport { useLineChartPrice } from './usePrice';\nimport type { TFormatterFn } from '../candle/types';\nimport { AnimatedText } from '../../components/AnimatedText';\n\nexport type LineChartPriceTextProps = {\n format?: TFormatterFn<string>;\n precision?: number;\n variant?: 'formatted' | 'value';\n style?: Animated.AnimateProps<RNTextProps>['style'];\n};\n\nexport function LineChartPriceText({\n format,\n precision = 2,\n variant = 'formatted',\n style,\n}: LineChartPriceTextProps) {\n const price = useLineChartPrice({ format, precision });\n return <AnimatedText text={price[variant]} style={style} />;\n}\n"]}
|