react-native-wagmi-charts 1.8.0 → 2.0.0
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/README.md +331 -196
- package/example/.DS_Store +0 -0
- package/example/src/LineChart.tsx +10 -4
- package/example/src/data/line-data.json +20 -20
- package/lib/commonjs/charts/candle/utils/getDomain.js +19 -0
- package/lib/commonjs/charts/candle/utils/getDomain.js.map +1 -0
- package/lib/commonjs/charts/candle/utils/getHeight.js +19 -0
- package/lib/commonjs/charts/candle/utils/getHeight.js.map +1 -0
- package/lib/commonjs/charts/candle/utils/getPrice.js +20 -0
- package/lib/commonjs/charts/candle/utils/getPrice.js.map +1 -0
- package/lib/commonjs/charts/candle/utils/getY.js +19 -0
- package/lib/commonjs/charts/candle/utils/getY.js.map +1 -0
- package/lib/commonjs/charts/candle/utils/index.js +58 -0
- package/lib/commonjs/charts/candle/utils/index.js.map +1 -0
- package/lib/commonjs/charts/line/Chart.js +9 -3
- package/lib/commonjs/charts/line/Chart.js.map +1 -1
- package/lib/commonjs/charts/line/ChartPath.js +73 -17
- package/lib/commonjs/charts/line/ChartPath.js.map +1 -1
- package/lib/commonjs/charts/line/Context.js +1 -0
- package/lib/commonjs/charts/line/Context.js.map +1 -1
- package/lib/commonjs/charts/line/Cursor.js +1 -0
- package/lib/commonjs/charts/line/Cursor.js.map +1 -1
- package/lib/commonjs/charts/line/CursorCrosshair.js +10 -3
- package/lib/commonjs/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/commonjs/charts/line/CursorLine.js +6 -6
- package/lib/commonjs/charts/line/CursorLine.js.map +1 -1
- package/lib/commonjs/charts/line/DatetimeText.js +2 -0
- package/lib/commonjs/charts/line/DatetimeText.js.map +1 -1
- package/lib/commonjs/charts/line/Dot.js +67 -62
- package/lib/commonjs/charts/line/Dot.js.map +1 -1
- package/lib/commonjs/charts/line/Gradient.js +8 -25
- package/lib/commonjs/charts/line/Gradient.js.map +1 -1
- package/lib/commonjs/charts/line/Group.js +5 -25
- package/lib/commonjs/charts/line/Group.js.map +1 -1
- package/lib/commonjs/charts/line/Highlight.js +92 -0
- package/lib/commonjs/charts/line/Highlight.js.map +1 -0
- package/lib/commonjs/charts/line/HorizontalLine.js +6 -6
- package/lib/commonjs/charts/line/HorizontalLine.js.map +1 -1
- package/lib/commonjs/charts/line/Path.js +19 -30
- package/lib/commonjs/charts/line/Path.js.map +1 -1
- package/lib/commonjs/charts/line/PriceText.js +2 -0
- package/lib/commonjs/charts/line/PriceText.js.map +1 -1
- package/lib/commonjs/charts/line/Tooltip.js +2 -0
- package/lib/commonjs/charts/line/Tooltip.js.map +1 -1
- package/lib/commonjs/charts/line/index.js +47 -20
- package/lib/commonjs/charts/line/index.js.map +1 -1
- package/lib/commonjs/charts/line/useAnimatedPath.js +44 -0
- package/lib/commonjs/charts/line/useAnimatedPath.js.map +1 -0
- package/lib/commonjs/charts/line/{utils.js → utils/getArea.js} +2 -49
- package/lib/commonjs/charts/line/utils/getArea.js.map +1 -0
- package/lib/commonjs/charts/line/utils/getDomain.js +16 -0
- package/lib/commonjs/charts/line/utils/getDomain.js.map +1 -0
- package/lib/commonjs/charts/line/utils/getPath.js +34 -0
- package/lib/commonjs/charts/line/utils/getPath.js.map +1 -0
- package/lib/commonjs/charts/line/utils/index.js +71 -0
- package/lib/commonjs/charts/line/utils/index.js.map +1 -0
- package/lib/commonjs/charts/line/{interpolatePath.js → utils/interpolatePath.js} +1 -1
- package/lib/commonjs/charts/line/{interpolatePath.js.map → utils/interpolatePath.js.map} +1 -1
- package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js +27 -0
- package/lib/commonjs/charts/line/utils/lineChartDataPropToArray.js.map +1 -0
- package/lib/commonjs/index.js +8 -8
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/utils/formatDatetime.js +21 -0
- package/lib/commonjs/utils/formatDatetime.js.map +1 -0
- package/lib/commonjs/utils/formatPrice.js +46 -0
- package/lib/commonjs/utils/formatPrice.js.map +1 -0
- package/lib/commonjs/utils/index.js +45 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/{utils.js → utils/usePrevious.js} +1 -57
- package/lib/commonjs/utils/usePrevious.js.map +1 -0
- package/lib/module/charts/candle/utils/getDomain.js +12 -0
- package/lib/module/charts/candle/utils/getDomain.js.map +1 -0
- package/lib/module/charts/candle/utils/getHeight.js +11 -0
- package/lib/module/charts/candle/utils/getHeight.js.map +1 -0
- package/lib/module/charts/candle/utils/getPrice.js +12 -0
- package/lib/module/charts/candle/utils/getPrice.js.map +1 -0
- package/lib/module/charts/candle/utils/getY.js +11 -0
- package/lib/module/charts/candle/utils/getY.js.map +1 -0
- package/lib/module/charts/candle/utils/index.js +5 -0
- package/lib/module/charts/candle/utils/index.js.map +1 -0
- package/lib/module/charts/line/Chart.js +9 -4
- package/lib/module/charts/line/Chart.js.map +1 -1
- package/lib/module/charts/line/ChartPath.js +69 -17
- package/lib/module/charts/line/ChartPath.js.map +1 -1
- package/lib/module/charts/line/Context.js +1 -0
- package/lib/module/charts/line/Context.js.map +1 -1
- package/lib/module/charts/line/Cursor.js +1 -0
- package/lib/module/charts/line/Cursor.js.map +1 -1
- package/lib/module/charts/line/CursorCrosshair.js +10 -4
- package/lib/module/charts/line/CursorCrosshair.js.map +1 -1
- package/lib/module/charts/line/CursorLine.js +4 -3
- package/lib/module/charts/line/CursorLine.js.map +1 -1
- package/lib/module/charts/line/DatetimeText.js +1 -0
- package/lib/module/charts/line/DatetimeText.js.map +1 -1
- package/lib/module/charts/line/Dot.js +66 -63
- package/lib/module/charts/line/Dot.js.map +1 -1
- package/lib/module/charts/line/Gradient.js +8 -24
- package/lib/module/charts/line/Gradient.js.map +1 -1
- package/lib/module/charts/line/Group.js +2 -24
- package/lib/module/charts/line/Group.js.map +1 -1
- package/lib/module/charts/line/Highlight.js +69 -0
- package/lib/module/charts/line/Highlight.js.map +1 -0
- package/lib/module/charts/line/HorizontalLine.js +4 -3
- package/lib/module/charts/line/HorizontalLine.js.map +1 -1
- package/lib/module/charts/line/Path.js +17 -29
- package/lib/module/charts/line/Path.js.map +1 -1
- package/lib/module/charts/line/PriceText.js +1 -0
- package/lib/module/charts/line/PriceText.js.map +1 -1
- package/lib/module/charts/line/Tooltip.js +1 -0
- package/lib/module/charts/line/Tooltip.js.map +1 -1
- package/lib/module/charts/line/index.js +12 -8
- package/lib/module/charts/line/index.js.map +1 -1
- package/lib/module/charts/line/useAnimatedPath.js +34 -0
- package/lib/module/charts/line/useAnimatedPath.js.map +1 -0
- package/lib/module/charts/line/utils/getArea.js +19 -0
- package/lib/module/charts/line/utils/getArea.js.map +1 -0
- package/lib/module/charts/line/utils/getDomain.js +9 -0
- package/lib/module/charts/line/utils/getDomain.js.map +1 -0
- package/lib/module/charts/line/utils/getPath.js +21 -0
- package/lib/module/charts/line/utils/getPath.js.map +1 -0
- package/lib/module/charts/line/utils/index.js +6 -0
- package/lib/module/charts/line/utils/index.js.map +1 -0
- package/lib/module/charts/line/{interpolatePath.js → utils/interpolatePath.js} +1 -1
- package/lib/module/charts/line/{interpolatePath.js.map → utils/interpolatePath.js.map} +1 -1
- package/lib/module/charts/line/utils/lineChartDataPropToArray.js +20 -0
- package/lib/module/charts/line/utils/lineChartDataPropToArray.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/utils/formatDatetime.js +14 -0
- package/lib/module/utils/formatDatetime.js.map +1 -0
- package/lib/module/{utils.js → utils/formatPrice.js} +1 -29
- package/lib/module/utils/formatPrice.js.map +1 -0
- package/lib/module/utils/index.js +4 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/usePrevious.js +14 -0
- package/lib/module/utils/usePrevious.js.map +1 -0
- package/lib/typescript/src/charts/candle/utils/getDomain.d.ts +2 -0
- package/lib/typescript/src/charts/candle/utils/getHeight.d.ts +6 -0
- package/lib/typescript/src/charts/candle/utils/getPrice.d.ts +6 -0
- package/lib/typescript/src/charts/candle/utils/getY.d.ts +6 -0
- package/lib/typescript/src/charts/candle/utils/index.d.ts +4 -0
- package/lib/typescript/src/charts/line/Chart.d.ts +5 -1
- package/lib/typescript/src/charts/line/ChartPath.d.ts +10 -1
- package/lib/typescript/src/charts/line/Context.d.ts +3 -0
- package/lib/typescript/src/charts/line/Cursor.d.ts +3 -0
- package/lib/typescript/src/charts/line/CursorCrosshair.d.ts +4 -1
- package/lib/typescript/src/charts/line/CursorLine.d.ts +4 -1
- package/lib/typescript/src/charts/line/DatetimeText.d.ts +3 -0
- package/lib/typescript/src/charts/line/Dot.d.ts +10 -7
- package/lib/typescript/src/charts/line/Gradient.d.ts +3 -0
- package/lib/typescript/src/charts/line/Group.d.ts +1 -2
- package/lib/typescript/src/charts/line/Highlight.d.ts +15 -0
- package/lib/typescript/src/charts/line/HorizontalLine.d.ts +4 -1
- package/lib/typescript/src/charts/line/Path.d.ts +5 -1
- package/lib/typescript/src/charts/line/PriceText.d.ts +3 -0
- package/lib/typescript/src/charts/line/Tooltip.d.ts +3 -0
- package/lib/typescript/src/charts/line/index.d.ts +15 -25
- package/lib/typescript/src/charts/line/useAnimatedPath.d.ts +8 -0
- package/lib/typescript/src/charts/line/utils/getArea.d.ts +9 -0
- package/lib/typescript/src/charts/line/utils/getDomain.d.ts +2 -0
- package/lib/typescript/src/charts/line/utils/getPath.d.ts +11 -0
- package/lib/typescript/src/charts/line/utils/index.d.ts +5 -0
- package/lib/typescript/src/charts/line/{interpolatePath.d.ts → utils/interpolatePath.d.ts} +1 -1
- package/lib/typescript/src/charts/line/utils/lineChartDataPropToArray.d.ts +2 -0
- package/lib/typescript/src/index.d.ts +1 -1
- package/lib/typescript/src/utils/formatDatetime.d.ts +8 -0
- package/lib/typescript/src/utils/formatPrice.d.ts +8 -0
- package/lib/typescript/src/utils/index.d.ts +3 -0
- package/lib/typescript/src/utils/usePrevious.d.ts +1 -0
- package/package.json +4 -2
- package/src/charts/candle/utils/getDomain.ts +9 -0
- package/src/charts/candle/utils/getHeight.ts +21 -0
- package/src/charts/candle/utils/getPrice.ts +17 -0
- package/src/charts/candle/utils/getY.ts +16 -0
- package/src/charts/candle/utils/index.ts +4 -0
- package/src/charts/line/Chart.tsx +9 -3
- package/src/charts/line/ChartPath.tsx +109 -33
- package/src/charts/line/Context.tsx +2 -0
- package/src/charts/line/Cursor.tsx +2 -0
- package/src/charts/line/CursorCrosshair.tsx +20 -5
- package/src/charts/line/CursorLine.tsx +5 -3
- package/src/charts/line/DatetimeText.tsx +2 -0
- package/src/charts/line/Dot.tsx +83 -86
- package/src/charts/line/Gradient.tsx +7 -34
- package/src/charts/line/Group.tsx +4 -47
- package/src/charts/line/Highlight.tsx +78 -0
- package/src/charts/line/HorizontalLine.tsx +5 -3
- package/src/charts/line/Path.tsx +14 -38
- package/src/charts/line/PriceText.tsx +2 -0
- package/src/charts/line/Tooltip.tsx +2 -0
- package/src/charts/line/index.ts +11 -7
- package/src/charts/line/useAnimatedPath.ts +47 -0
- package/src/charts/line/utils/getArea.ts +38 -0
- package/src/charts/line/utils/getDomain.ts +7 -0
- package/src/charts/line/utils/getPath.ts +48 -0
- package/src/charts/line/utils/index.ts +5 -0
- package/src/charts/line/{interpolatePath.ts → utils/interpolatePath.ts} +1 -1
- package/src/charts/line/utils/lineChartDataPropToArray.ts +25 -0
- package/src/index.ts +1 -1
- package/src/utils/formatDatetime.ts +16 -0
- package/src/{utils.ts → utils/formatPrice.ts} +0 -31
- package/src/utils/index.ts +3 -0
- package/src/utils/usePrevious.ts +13 -0
- package/yarn.lock +8 -1
- package/lib/commonjs/charts/line/utils.js.map +0 -1
- package/lib/commonjs/utils.js.map +0 -1
- package/lib/module/charts/line/utils.js +0 -60
- package/lib/module/charts/line/utils.js.map +0 -1
- package/lib/module/utils.js.map +0 -1
- package/lib/typescript/src/charts/line/utils.d.ts +0 -20
- package/lib/typescript/src/utils.d.ts +0 -17
- package/src/charts/line/utils.ts +0 -100
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Cursor.tsx"],"names":["CursorContext","React","createContext","type","LineChartCursor","children","props","pathWidth","width","path","useContext","LineChartDimensionsContext","currentX","currentIndex","isActive","data","parsedPath","useMemo","undefined","onGestureEvent","onActive","x","boundedX","value","minIndex","boundedIndex","Math","max","round","length","onEnd","StyleSheet","absoluteFill"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AAMA;;AACA;;AAEA;;AACA;;;;;;;;AAOO,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAN,CAAoB;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAApB,CAAtB
|
|
1
|
+
{"version":3,"sources":["Cursor.tsx"],"names":["CursorContext","React","createContext","type","LineChartCursor","displayName","children","props","pathWidth","width","path","useContext","LineChartDimensionsContext","currentX","currentIndex","isActive","data","parsedPath","useMemo","undefined","onGestureEvent","onActive","x","boundedX","value","minIndex","boundedIndex","Math","max","round","length","onEnd","StyleSheet","absoluteFill"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AAMA;;AACA;;AAEA;;AACA;;;;;;;;AAOO,MAAMA,aAAa,gBAAGC,KAAK,CAACC,aAAN,CAAoB;AAAEC,EAAAA,IAAI,EAAE;AAAR,CAApB,CAAtB;;AAEPC,eAAe,CAACC,WAAhB,GAA8B,iBAA9B;;AAEO,SAASD,eAAT,CAAyB;AAC9BE,EAAAA,QAD8B;AAE9BH,EAAAA,IAF8B;AAG9B,KAAGI;AAH2B,CAAzB,EAIkB;AACvB,QAAM;AAAEC,IAAAA,SAAS,EAAEC,KAAb;AAAoBC,IAAAA;AAApB,MAA6BT,KAAK,CAACU,UAAN,CACjCC,iCADiC,CAAnC;AAGA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,YAAZ;AAA0BC,IAAAA,QAA1B;AAAoCC,IAAAA;AAApC,MAA6C,iCAAnD;AAEA,QAAMC,UAAU,GAAGhB,KAAK,CAACiB,OAAN,CACjB,MAAOR,IAAI,GAAG,8BAAMA,IAAN,CAAH,GAAiBS,SADX,EAEjB,CAACT,IAAD,CAFiB,CAAnB;AAKA,QAAMU,cAAc,GAAG,sDAErB;AACAC,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;AACAX,QAAAA,QAAQ,CAACW,KAAT,GAAiBD,QAAjB,CAHc,CAKd;AACA;AACA;;AACA,cAAME,QAAQ,GAAG,CAAjB;AACA,cAAMC,YAAY,GAAGC,IAAI,CAACC,GAAL,CACnBH,QADmB,EAEnBE,IAAI,CAACE,KAAL,CAAWN,QAAQ,GAAGd,KAAX,IAAoB,KAAKO,IAAI,CAACc,MAAL,GAAc,CAAnB,CAApB,CAAX,CAFmB,CAArB;AAKAhB,QAAAA,YAAY,CAACU,KAAb,GAAqBE,YAArB;AACD;AACF,KAlBD;AAmBAK,IAAAA,KAAK,EAAE,MAAM;AACXhB,MAAAA,QAAQ,CAACS,KAAT,GAAiB,KAAjB;AACAV,MAAAA,YAAY,CAACU,KAAb,GAAqB,CAAC,CAAtB;AACD;AAtBD,GAFqB,CAAvB;AA2BA,sBACE,oBAAC,aAAD,CAAe,QAAf;AAAwB,IAAA,KAAK,EAAE;AAAErB,MAAAA;AAAF;AAA/B,kBACE,oBAAC,kDAAD;AACE,IAAA,aAAa,EAAE,CADjB;AAEE,IAAA,OAAO,EAAE,MAFX;AAGE,IAAA,cAAc,EAAEiB;AAHlB,KAIMb,KAJN,gBAME,oBAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEyB,wBAAWC;AAAjC,KACG3B,QADH,CANF,CADF,CADF;AAcD","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 { 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\nLineChartCursor.displayName = 'LineChartCursor';\n\nexport function LineChartCursor({\n children,\n type,\n ...props\n}: LineChartCursorProps) {\n const { pathWidth: width, path } = React.useContext(\n LineChartDimensionsContext\n );\n const { currentX, 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\n // on Web, we could drag the cursor to be negative, breaking it\n // so we clamp the index at 0 to fix it\n // https://github.com/coinjar/react-native-wagmi-charts/issues/24\n const minIndex = 0;\n const boundedIndex = Math.max(\n minIndex,\n Math.round(boundedX / width / (1 / (data.length - 1)))\n );\n\n currentIndex.value = boundedIndex;\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 maxDist={999999}\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"]}
|
|
@@ -21,6 +21,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
21
21
|
|
|
22
22
|
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); }
|
|
23
23
|
|
|
24
|
+
LineChartCursorCrosshair.displayName = 'LineChartCursorCrosshair';
|
|
25
|
+
|
|
24
26
|
function LineChartCursorCrosshair({
|
|
25
27
|
children,
|
|
26
28
|
color = 'black',
|
|
@@ -35,16 +37,21 @@ function LineChartCursorCrosshair({
|
|
|
35
37
|
currentX,
|
|
36
38
|
currentY,
|
|
37
39
|
isActive
|
|
38
|
-
} = (0, _useLineChart.useLineChart)();
|
|
40
|
+
} = (0, _useLineChart.useLineChart)(); // It seems that enabling spring animation on initial render on Android causes a crash.
|
|
41
|
+
|
|
42
|
+
const [enableSpringAnimation, setEnableSpringAnimation] = React.useState(_reactNative.Platform.OS === 'ios');
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
setEnableSpringAnimation(true);
|
|
45
|
+
}, []);
|
|
39
46
|
const animatedCursorStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
|
|
40
47
|
transform: [{
|
|
41
48
|
translateX: currentX.value - outerSize / 2
|
|
42
49
|
}, {
|
|
43
50
|
translateY: currentY.value - outerSize / 2
|
|
44
51
|
}, {
|
|
45
|
-
scale: (0, _reactNativeReanimated.withSpring)(isActive.value ? 1 : 0, {
|
|
52
|
+
scale: enableSpringAnimation ? (0, _reactNativeReanimated.withSpring)(isActive.value ? 1 : 0, {
|
|
46
53
|
damping: 10
|
|
47
|
-
})
|
|
54
|
+
}) : 0
|
|
48
55
|
}]
|
|
49
56
|
}));
|
|
50
57
|
return /*#__PURE__*/React.createElement(_Cursor.LineChartCursor, _extends({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CursorCrosshair.tsx"],"names":["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;;AACA;;AACA;;AAKA;;AACA;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["CursorCrosshair.tsx"],"names":["LineChartCursorCrosshair","displayName","children","color","size","outerSize","crosshairWrapperProps","crosshairProps","crosshairOuterProps","props","currentX","currentY","isActive","enableSpringAnimation","setEnableSpringAnimation","React","useState","Platform","OS","useEffect","animatedCursorStyle","transform","translateX","value","translateY","scale","damping","width","height","alignItems","justifyContent","style","backgroundColor","borderRadius","opacity","position"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAKA;;AACA;;;;;;;;AAeAA,wBAAwB,CAACC,WAAzB,GAAuC,0BAAvC;;AAEO,SAASD,wBAAT,CAAkC;AACvCE,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;AAAYC,IAAAA,QAAZ;AAAsBC,IAAAA;AAAtB,MAAmC,iCAAzC,CADgC,CAGhC;;AACA,QAAM,CAACC,qBAAD,EAAwBC,wBAAxB,IAAoDC,KAAK,CAACC,QAAN,CACxDC,sBAASC,EAAT,KAAgB,KADwC,CAA1D;AAGAH,EAAAA,KAAK,CAACI,SAAN,CAAgB,MAAM;AACpBL,IAAAA,wBAAwB,CAAC,IAAD,CAAxB;AACD,GAFD,EAEG,EAFH;AAIA,QAAMM,mBAAmB,GAAG,6CAAiB,OAAO;AAClDC,IAAAA,SAAS,EAAE,CACT;AAAEC,MAAAA,UAAU,EAAEZ,QAAQ,CAACa,KAAT,GAAiBlB,SAAS,GAAG;AAA3C,KADS,EAET;AAAEmB,MAAAA,U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';\nimport { Platform, 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<\n LineChartCursorProps,\n 'children' | 'type'\n> & {\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\nLineChartCursorCrosshair.displayName = 'LineChartCursorCrosshair';\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 // It seems that enabling spring animation on initial render on Android causes a crash.\n const [enableSpringAnimation, setEnableSpringAnimation] = React.useState(\n Platform.OS === 'ios'\n );\n React.useEffect(() => {\n setEnableSpringAnimation(true);\n }, []);\n\n const animatedCursorStyle = useAnimatedStyle(() => ({\n transform: [\n { translateX: currentX.value - outerSize / 2 },\n { translateY: currentY.value - outerSize / 2 },\n {\n scale: enableSpringAnimation\n ? withSpring(isActive.value ? 1 : 0, {\n damping: 10,\n })\n : 0,\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"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.LineChartCursorLine =
|
|
6
|
+
exports.LineChartCursorLine = LineChartCursorLine;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -27,11 +27,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
27
|
|
|
28
28
|
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); }
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
LineChartCursorLine.displayName = 'LineChartCursorLine';
|
|
31
|
+
|
|
32
|
+
function LineChartCursorLine({
|
|
31
33
|
children,
|
|
32
34
|
color = 'gray',
|
|
33
35
|
lineProps = {}
|
|
34
|
-
})
|
|
36
|
+
}) {
|
|
35
37
|
const {
|
|
36
38
|
height
|
|
37
39
|
} = _react.default.useContext(_Chart.LineChartDimensionsContext);
|
|
@@ -62,9 +64,7 @@ const LineChartCursorLine = ({
|
|
|
62
64
|
stroke: color,
|
|
63
65
|
strokeDasharray: "3 3"
|
|
64
66
|
}, lineProps)))), children);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
exports.LineChartCursorLine = LineChartCursorLine;
|
|
67
|
+
}
|
|
68
68
|
|
|
69
69
|
const styles = _reactNative.StyleSheet.create({
|
|
70
70
|
svg: { ..._reactNative.StyleSheet.absoluteFillObject,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["CursorLine.tsx"],"names":["LineChartCursorLine","children","color","lineProps","height","React","useContext","LineChartDimensionsContext","currentX","isActive","vertical","opacity","value","transform","translateX","styles","svg","StyleSheet","create","absoluteFillObject"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["CursorLine.tsx"],"names":["LineChartCursorLine","displayName","children","color","lineProps","height","React","useContext","LineChartDimensionsContext","currentX","isActive","vertical","opacity","value","transform","translateX","styles","svg","StyleSheet","create","absoluteFillObject"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAQAA,mBAAmB,CAACC,WAApB,GAAkC,qBAAlC;;AAEO,SAASD,mBAAT,CAA6B;AAClCE,EAAAA,QADkC;AAElCC,EAAAA,KAAK,GAAG,MAF0B;AAGlCC,EAAAA,SAAS,GAAG;AAHsB,CAA7B,EAIsB;AAC3B,QAAM;AAAEC,IAAAA;AAAF,MAAaC,eAAMC,UAAN,CAAiBC,iCAAjB,CAAnB;;AACA,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAyB,iCAA/B;AAEA,QAAMC,QAAQ,GAAG,6CAAiB,OAAO;AACvCC,IAAAA,OAAO,EAAEF,QAAQ,CAACG,KAAT,GAAiB,CAAjB,GAAqB,CADS;AAEvCR,IAAAA,MAAM,EAAE,MAF+B;AAGvCS,IAAAA,SAAS,EAAE,CAAC;AAAEC,MAAAA,UAAU,EAAEN,QAAQ,CAACI;AAAvB,KAAD;AAH4B,GAAP,CAAjB,CAAjB;AAMA,sBACE,6BAAC,uBAAD;AAAiB,IAAA,IAAI,EAAC;AAAtB,kBACE,6BAAC,8BAAD,CAAU,IAAV;AAAe,IAAA,KAAK,EAAEF;AAAtB,kBACE,6BAAC,uBAAD;AAAK,IAAA,KAAK,EAAEK,MAAM,CAACC;AAAnB,kBACE,6BAAC,oBAAD;AACE,IAAA,EAAE,EAAE,CADN;AAEE,IAAA,EAAE,EAAE,CAFN;AAGE,IAAA,EAAE,EAAE,CAHN;AAIE,IAAA,EAAE,EAAEZ,MAJN;AAKE,IAAA,WAAW,EAAE,CALf;AAME,IAAA,MAAM,EAAEF,KANV;AAOE,IAAA,eAAe,EAAC;AAPlB,KAQMC,SARN,EADF,CADF,CADF,EAeGF,QAfH,CADF;AAmBD;;AAED,MAAMc,MAAM,GAAGE,wBAAWC,MAAX,CAAkB;AAC/BF,EAAAA,GAAG,EAAE,EACH,GAAGC,wBAAWE,kBADX;AAEH;AACAf,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\nLineChartCursorLine.displayName = 'LineChartCursorLine';\n\nexport function 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"]}
|
|
@@ -15,6 +15,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
|
|
18
|
+
LineChartDatetimeText.displayName = 'LineChartDatetimeText';
|
|
19
|
+
|
|
18
20
|
function LineChartDatetimeText({
|
|
19
21
|
locale,
|
|
20
22
|
options,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["DatetimeText.tsx"],"names":["LineChartDatetimeText","locale","options","format","variant","style","datetime"],"mappings":";;;;;;;AAAA;;AAIA;;AAEA;;;;;;
|
|
1
|
+
{"version":3,"sources":["DatetimeText.tsx"],"names":["LineChartDatetimeText","displayName","locale","options","format","variant","style","datetime"],"mappings":";;;;;;;AAAA;;AAIA;;AAEA;;;;;;AAUAA,qBAAqB,CAACC,WAAtB,GAAoC,uBAApC;;AAEO,SAASD,qBAAT,CAA+B;AACpCE,EAAAA,MADoC;AAEpCC,EAAAA,OAFoC;AAGpCC,EAAAA,MAHoC;AAIpCC,EAAAA,OAAO,GAAG,WAJ0B;AAKpCC,EAAAA;AALoC,CAA/B,EAMoB;AACzB,QAAMC,QAAQ,GAAG,uCAAqB;AAAEH,IAAAA,MAAF;AAAUF,IAAAA,MAAV;AAAkBC,IAAAA;AAAlB,GAArB,CAAjB;AACA,sBAAO,oBAAC,0BAAD;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\nLineChartDatetimeText.displayName = 'LineChartDatetimeText';\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"]}
|
|
@@ -9,12 +9,14 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
|
|
10
10
|
var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _reactNativeSvg = require("react-native-svg");
|
|
13
13
|
|
|
14
14
|
var _reactNativeRedash = require("react-native-redash");
|
|
15
15
|
|
|
16
16
|
var _Chart = require("./Chart");
|
|
17
17
|
|
|
18
|
+
var _ChartPath = require("./ChartPath");
|
|
19
|
+
|
|
18
20
|
var _useLineChart = require("./useLineChart");
|
|
19
21
|
|
|
20
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -23,16 +25,23 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
23
25
|
|
|
24
26
|
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); }
|
|
25
27
|
|
|
28
|
+
const AnimatedCircle = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Circle);
|
|
29
|
+
|
|
26
30
|
LineChartDot.displayName = 'LineChartDot';
|
|
27
31
|
|
|
28
32
|
function LineChartDot({
|
|
29
|
-
color = 'black',
|
|
30
33
|
at,
|
|
31
|
-
|
|
32
|
-
pulsesOuter = 'while-inactive',
|
|
33
|
-
outerSize = size * 4,
|
|
34
|
+
color: defaultColor = 'black',
|
|
34
35
|
dotProps,
|
|
35
|
-
|
|
36
|
+
hasOuterDot: defaultHasOuterDot = false,
|
|
37
|
+
hasPulse = false,
|
|
38
|
+
inactiveColor,
|
|
39
|
+
outerDotProps,
|
|
40
|
+
pulseBehaviour = 'while-inactive',
|
|
41
|
+
pulseDurationMs = 800,
|
|
42
|
+
showInactiveColor = true,
|
|
43
|
+
size = 4,
|
|
44
|
+
outerSize = size * 4
|
|
36
45
|
}) {
|
|
37
46
|
const {
|
|
38
47
|
data,
|
|
@@ -41,81 +50,77 @@ function LineChartDot({
|
|
|
41
50
|
const {
|
|
42
51
|
path,
|
|
43
52
|
pathWidth: width
|
|
44
|
-
} = React.useContext(_Chart.LineChartDimensionsContext);
|
|
45
|
-
|
|
46
|
-
const
|
|
53
|
+
} = React.useContext(_Chart.LineChartDimensionsContext); ////////////////////////////////////////////////////////////
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
isInactive: _isInactive
|
|
57
|
+
} = React.useContext(_ChartPath.LineChartPathContext);
|
|
58
|
+
const isInactive = showInactiveColor && _isInactive;
|
|
59
|
+
const color = isInactive ? inactiveColor || defaultColor : defaultColor;
|
|
60
|
+
const opacity = isInactive && !inactiveColor ? 0.5 : 1;
|
|
61
|
+
const hasOuterDot = defaultHasOuterDot || hasPulse; ////////////////////////////////////////////////////////////
|
|
62
|
+
|
|
63
|
+
const parsedPath = React.useMemo(() => (0, _reactNativeRedash.parse)(path), [path]); ////////////////////////////////////////////////////////////
|
|
64
|
+
|
|
65
|
+
const pointWidth = React.useMemo(() => width / (data.length - 1), [data.length, width]); ////////////////////////////////////////////////////////////
|
|
66
|
+
|
|
47
67
|
const x = (0, _reactNativeReanimated.useDerivedValue)(() => (0, _reactNativeReanimated.withTiming)(pointWidth * at));
|
|
48
|
-
const y = (0, _reactNativeReanimated.useDerivedValue)(() => (0, _reactNativeReanimated.withTiming)((0, _reactNativeRedash.getYForX)(parsedPath, x.value) || 0));
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
const y = (0, _reactNativeReanimated.useDerivedValue)(() => (0, _reactNativeReanimated.withTiming)((0, _reactNativeRedash.getYForX)(parsedPath, x.value) || 0)); ////////////////////////////////////////////////////////////
|
|
69
|
+
|
|
70
|
+
const animatedDotProps = (0, _reactNativeReanimated.useAnimatedProps)(() => ({
|
|
71
|
+
cx: x.value,
|
|
72
|
+
cy: y.value
|
|
73
|
+
}));
|
|
74
|
+
const animatedOuterDotProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
|
|
75
|
+
let defaultProps = {
|
|
76
|
+
cx: x.value,
|
|
77
|
+
cy: y.value,
|
|
78
|
+
opacity: 0.1,
|
|
79
|
+
r: outerSize
|
|
56
80
|
};
|
|
57
|
-
});
|
|
58
|
-
const outerStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => {
|
|
59
|
-
let opacity = 0.1;
|
|
60
81
|
|
|
61
|
-
if (
|
|
62
|
-
return
|
|
63
|
-
opacity
|
|
64
|
-
};
|
|
82
|
+
if (!hasPulse) {
|
|
83
|
+
return defaultProps;
|
|
65
84
|
}
|
|
66
85
|
|
|
67
|
-
|
|
86
|
+
if (isActive.value && pulseBehaviour === 'while-inactive') {
|
|
87
|
+
return { ...defaultProps,
|
|
88
|
+
r: 0
|
|
89
|
+
};
|
|
90
|
+
}
|
|
68
91
|
|
|
69
92
|
const easing = _reactNativeReanimated.Easing.out(_reactNativeReanimated.Easing.sin);
|
|
70
93
|
|
|
71
94
|
const animatedOpacity = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0.8), (0, _reactNativeReanimated.withTiming)(0, {
|
|
72
|
-
duration:
|
|
95
|
+
duration: pulseDurationMs,
|
|
73
96
|
easing
|
|
74
97
|
})), -1, false);
|
|
75
|
-
const scale = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0), (0, _reactNativeReanimated.withTiming)(
|
|
76
|
-
duration:
|
|
98
|
+
const scale = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withSequence)((0, _reactNativeReanimated.withTiming)(0), (0, _reactNativeReanimated.withTiming)(outerSize, {
|
|
99
|
+
duration: pulseDurationMs,
|
|
77
100
|
easing
|
|
78
101
|
})), -1, false);
|
|
79
102
|
|
|
80
|
-
if (
|
|
81
|
-
return {
|
|
103
|
+
if (pulseBehaviour === 'while-inactive') {
|
|
104
|
+
return { ...defaultProps,
|
|
82
105
|
opacity: isActive.value ? (0, _reactNativeReanimated.withTiming)(0) : animatedOpacity,
|
|
83
|
-
|
|
84
|
-
scale: isActive.value ? (0, _reactNativeReanimated.withTiming)(0) : scale
|
|
85
|
-
}]
|
|
106
|
+
r: isActive.value ? (0, _reactNativeReanimated.withTiming)(0) : scale
|
|
86
107
|
};
|
|
87
108
|
}
|
|
88
109
|
|
|
89
|
-
return {
|
|
110
|
+
return { ...defaultProps,
|
|
90
111
|
opacity: animatedOpacity,
|
|
91
|
-
|
|
92
|
-
scale
|
|
93
|
-
}]
|
|
112
|
+
r: scale
|
|
94
113
|
};
|
|
95
|
-
}, [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
backgroundColor: color,
|
|
107
|
-
width: outerSize,
|
|
108
|
-
height: outerSize,
|
|
109
|
-
borderRadius: outerSize,
|
|
110
|
-
position: 'absolute'
|
|
111
|
-
}, outerStyle, outerDotProps === null || outerDotProps === void 0 ? void 0 : outerDotProps.style], [color, outerSize, outerStyle, outerDotProps === null || outerDotProps === void 0 ? void 0 : outerDotProps.style])
|
|
112
|
-
})), /*#__PURE__*/React.createElement(_reactNative.View, _extends({}, dotProps, {
|
|
113
|
-
style: (0, React.useMemo)(() => [{
|
|
114
|
-
backgroundColor: color,
|
|
115
|
-
width: size,
|
|
116
|
-
height: size,
|
|
117
|
-
borderRadius: size
|
|
118
|
-
}, dotProps === null || dotProps === void 0 ? void 0 : dotProps.style], [color, size, dotProps === null || dotProps === void 0 ? void 0 : dotProps.style])
|
|
119
|
-
})));
|
|
114
|
+
}, [outerSize]); ////////////////////////////////////////////////////////////
|
|
115
|
+
|
|
116
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AnimatedCircle, _extends({
|
|
117
|
+
animatedProps: animatedDotProps,
|
|
118
|
+
r: size,
|
|
119
|
+
fill: color,
|
|
120
|
+
opacity: opacity
|
|
121
|
+
}, dotProps)), hasOuterDot && /*#__PURE__*/React.createElement(AnimatedCircle, _extends({
|
|
122
|
+
animatedProps: animatedOuterDotProps,
|
|
123
|
+
fill: color
|
|
124
|
+
}, outerDotProps)));
|
|
120
125
|
}
|
|
121
126
|
//# sourceMappingURL=Dot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Dot.tsx"],"names":["LineChartDot","displayName","color","
|
|
1
|
+
{"version":3,"sources":["Dot.tsx"],"names":["AnimatedCircle","Animated","createAnimatedComponent","Circle","LineChartDot","displayName","at","color","defaultColor","dotProps","hasOuterDot","defaultHasOuterDot","hasPulse","inactiveColor","outerDotProps","pulseBehaviour","pulseDurationMs","showInactiveColor","size","outerSize","data","isActive","path","pathWidth","width","React","useContext","LineChartDimensionsContext","isInactive","_isInactive","LineChartPathContext","opacity","parsedPath","useMemo","pointWidth","length","x","y","value","animatedDotProps","cx","cy","animatedOuterDotProps","defaultProps","r","easing","Easing","out","sin","animatedOpacity","duration","scale"],"mappings":";;;;;;;AAAA;;AACA;;AAQA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;AAEA,MAAMA,cAAc,GAAGC,+BAASC,uBAAT,CAAiCC,sBAAjC,CAAvB;;AA2BAC,YAAY,CAACC,WAAb,GAA2B,cAA3B;;AAEO,SAASD,YAAT,CAAsB;AAC3BE,EAAAA,EAD2B;AAE3BC,EAAAA,KAAK,EAAEC,YAAY,GAAG,OAFK;AAG3BC,EAAAA,QAH2B;AAI3BC,EAAAA,WAAW,EAAEC,kBAAkB,GAAG,KAJP;AAK3BC,EAAAA,QAAQ,GAAG,KALgB;AAM3BC,EAAAA,aAN2B;AAO3BC,EAAAA,aAP2B;AAQ3BC,EAAAA,cAAc,GAAG,gBARU;AAS3BC,EAAAA,eAAe,GAAG,GATS;AAU3BC,EAAAA,iBAAiB,GAAG,IAVO;AAW3BC,EAAAA,IAAI,GAAG,CAXoB;AAY3BC,EAAAA,SAAS,GAAGD,IAAI,GAAG;AAZQ,CAAtB,EAae;AACpB,QAAM;AAAEE,IAAAA,IAAF;AAAQC,IAAAA;AAAR,MAAqB,iCAA3B;AACA,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,SAAS,EAAEC;AAAnB,MAA6BC,KAAK,CAACC,UAAN,CACjCC,iCADiC,CAAnC,CAFoB,CAMpB;;AAEA,QAAM;AAAEC,IAAAA,UAAU,EAAEC;AAAd,MAA8BJ,KAAK,CAACC,UAAN,CAAiBI,+BAAjB,CAApC;AACA,QAAMF,UAAU,GAAGX,iBAAiB,IAAIY,WAAxC;AACA,QAAMtB,KAAK,GAAGqB,UAAU,GAAGf,aAAa,IAAIL,YAApB,GAAmC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MO,aAHN,EATJ,CADF;AAkBD","sourcesContent":["import * as React from 'react';\nimport Animated, {\n Easing,\n useAnimatedProps,\n useDerivedValue,\n withRepeat,\n withSequence,\n withTiming,\n} from 'react-native-reanimated';\nimport { Circle, CircleProps } from 'react-native-svg';\nimport { getYForX, parse } from 'react-native-redash';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { LineChartPathContext } from './ChartPath';\nimport { useLineChart } from './useLineChart';\n\nconst AnimatedCircle = Animated.createAnimatedComponent(Circle);\n\nexport type LineChartDotProps = {\n dotProps?: Animated.AnimateProps<CircleProps>;\n outerDotProps?: Animated.AnimateProps<CircleProps>;\n color?: string;\n inactiveColor?: string;\n showInactiveColor?: boolean;\n at: number;\n size?: number;\n hasPulse?: boolean;\n hasOuterDot?: boolean;\n /**\n * If `always`, the outer dot will still animate when interaction is active.\n *\n * If `while-inactive`, the outer dot will animate only when the interaction is inactive.\n *\n * Default: `while-inactive`\n */\n pulseBehaviour?: 'always' | 'while-inactive';\n /**\n * Defaults to `size * 4`\n */\n outerSize?: number;\n pulseDurationMs?: number;\n};\n\nLineChartDot.displayName = 'LineChartDot';\n\nexport function LineChartDot({\n at,\n color: defaultColor = 'black',\n dotProps,\n hasOuterDot: defaultHasOuterDot = false,\n hasPulse = false,\n inactiveColor,\n outerDotProps,\n pulseBehaviour = 'while-inactive',\n pulseDurationMs = 800,\n showInactiveColor = true,\n size = 4,\n outerSize = size * 4,\n}: LineChartDotProps) {\n const { data, isActive } = useLineChart();\n const { path, pathWidth: width } = React.useContext(\n LineChartDimensionsContext\n );\n\n ////////////////////////////////////////////////////////////\n\n const { isInactive: _isInactive } = React.useContext(LineChartPathContext);\n const isInactive = showInactiveColor && _isInactive;\n const color = isInactive ? inactiveColor || defaultColor : defaultColor;\n const opacity = isInactive && !inactiveColor ? 0.5 : 1;\n const hasOuterDot = defaultHasOuterDot || hasPulse;\n\n ////////////////////////////////////////////////////////////\n\n const parsedPath = React.useMemo(() => parse(path), [path]);\n\n ////////////////////////////////////////////////////////////\n\n const pointWidth = React.useMemo(\n () => width / (data.length - 1),\n [data.length, width]\n );\n\n ////////////////////////////////////////////////////////////\n\n const x = useDerivedValue(() => withTiming(pointWidth * at));\n const y = useDerivedValue(() =>\n withTiming(getYForX(parsedPath!, x.value) || 0)\n );\n\n ////////////////////////////////////////////////////////////\n\n const animatedDotProps = useAnimatedProps(() => ({\n cx: x.value,\n cy: y.value,\n }));\n\n const animatedOuterDotProps = useAnimatedProps(() => {\n let defaultProps = {\n cx: x.value,\n cy: y.value,\n opacity: 0.1,\n r: outerSize,\n };\n\n if (!hasPulse) {\n return defaultProps;\n }\n\n if (isActive.value && pulseBehaviour === 'while-inactive') {\n return {\n ...defaultProps,\n r: 0,\n };\n }\n\n const easing = Easing.out(Easing.sin);\n const animatedOpacity = withRepeat(\n withSequence(\n withTiming(0.8),\n withTiming(0, {\n duration: pulseDurationMs,\n easing,\n })\n ),\n -1,\n false\n );\n const scale = withRepeat(\n withSequence(\n withTiming(0),\n withTiming(outerSize, {\n duration: pulseDurationMs,\n easing,\n })\n ),\n -1,\n false\n );\n\n if (pulseBehaviour === 'while-inactive') {\n return {\n ...defaultProps,\n opacity: isActive.value ? withTiming(0) : animatedOpacity,\n r: isActive.value ? withTiming(0) : scale,\n };\n }\n return {\n ...defaultProps,\n opacity: animatedOpacity,\n r: scale,\n };\n }, [outerSize]);\n\n ////////////////////////////////////////////////////////////\n\n return (\n <>\n <AnimatedCircle\n animatedProps={animatedDotProps}\n r={size}\n fill={color}\n opacity={opacity}\n {...dotProps}\n />\n {hasOuterDot && (\n <AnimatedCircle\n animatedProps={animatedOuterDotProps}\n fill={color}\n {...outerDotProps}\n />\n )}\n </>\n );\n}\n"]}
|
|
@@ -7,7 +7,7 @@ exports.LineChartGradient = LineChartGradient;
|
|
|
7
7
|
|
|
8
8
|
var React = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
|
10
|
-
var _reactNativeReanimated =
|
|
10
|
+
var _reactNativeReanimated = _interopRequireDefault(require("react-native-reanimated"));
|
|
11
11
|
|
|
12
12
|
var _reactNativeSvg = require("react-native-svg");
|
|
13
13
|
|
|
@@ -15,9 +15,7 @@ var _Chart = require("./Chart");
|
|
|
15
15
|
|
|
16
16
|
var _ChartPath = require("./ChartPath");
|
|
17
17
|
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
var _utils = require("../../utils");
|
|
18
|
+
var _useAnimatedPath = _interopRequireDefault(require("./useAnimatedPath"));
|
|
21
19
|
|
|
22
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
21
|
|
|
@@ -30,6 +28,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
30
28
|
const AnimatedPath = _reactNativeReanimated.default.createAnimatedComponent(_reactNativeSvg.Path);
|
|
31
29
|
|
|
32
30
|
let id = 0;
|
|
31
|
+
LineChartGradient.displayName = 'LineChartGradient';
|
|
33
32
|
|
|
34
33
|
function LineChartGradient({
|
|
35
34
|
color: overrideColor = undefined,
|
|
@@ -45,27 +44,11 @@ function LineChartGradient({
|
|
|
45
44
|
} = React.useContext(_ChartPath.LineChartPathContext);
|
|
46
45
|
const color = overrideColor || contextColor; ////////////////////////////////////////////////
|
|
47
46
|
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
(0,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (previous) {
|
|
54
|
-
transition.value = 0;
|
|
55
|
-
transition.value = (0, _reactNativeReanimated.withTiming)(1);
|
|
56
|
-
}
|
|
57
|
-
}, [area]);
|
|
58
|
-
const animatedProps = (0, _reactNativeReanimated.useAnimatedProps)(() => {
|
|
59
|
-
let d = area || '';
|
|
60
|
-
|
|
61
|
-
if (previousPath && isTransitionEnabled) {
|
|
62
|
-
const pathInterpolator = (0, _interpolatePath.default)(previousPath, area, null);
|
|
63
|
-
d = pathInterpolator(transition.value);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return {
|
|
67
|
-
d
|
|
68
|
-
};
|
|
47
|
+
const {
|
|
48
|
+
animatedProps
|
|
49
|
+
} = (0, _useAnimatedPath.default)({
|
|
50
|
+
enabled: isTransitionEnabled,
|
|
51
|
+
path: area
|
|
69
52
|
}); ////////////////////////////////////////////////
|
|
70
53
|
|
|
71
54
|
const localId = React.useRef(++id); ////////////////////////////////////////////////
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Gradient.tsx"],"names":["AnimatedPath","Animated","createAnimatedComponent","Path","id","LineChartGradient","color","overrideColor","undefined","children","props","area","React","useContext","LineChartDimensionsContext","contextColor","isTransitionEnabled","LineChartPathContext","
|
|
1
|
+
{"version":3,"sources":["Gradient.tsx"],"names":["AnimatedPath","Animated","createAnimatedComponent","Path","id","LineChartGradient","displayName","color","overrideColor","undefined","children","props","area","React","useContext","LineChartDimensionsContext","contextColor","isTransitionEnabled","LineChartPathContext","animatedProps","enabled","path","localId","useRef","current"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;;;;;;;;;AAEA,MAAMA,YAAY,GAAGC,+BAASC,uBAAT,CAAiCC,oBAAjC,CAArB;;AAOA,IAAIC,EAAE,GAAG,CAAT;AAEAC,iBAAiB,CAACC,WAAlB,GAAgC,mBAAhC;;AAEO,SAASD,iBAAT,CAA2B;AAChCE,EAAAA,KAAK,EAAEC,aAAa,GAAGC,SADS;AAEhCC,EAAAA,QAFgC;AAGhC,KAAGC;AAH6B,CAA3B,EAIoB;AACzB,QAAM;AAAEC,IAAAA;AAAF,MAAWC,KAAK,CAACC,UAAN,CAAiBC,iCAAjB,CAAjB;AACA,QAAM;AAAER,IAAAA,KAAK,EAAES,YAAT;AAAuBC,IAAAA;AAAvB,MACJJ,KAAK,CAACC,UAAN,CAAiBI,+BAAjB,CADF;AAGA,QAAMX,KAAK,GAAGC,aAAa,IAAIQ,YAA/B,CALyB,CAOzB;;AAEA,QAAM;AAAEG,IAAAA;AAAF,MAAoB,8BAAgB;AACxCC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defs, LinearGradient, Stop, Path, PathProps } from 'react-native-svg';\n\nimport { LineChartDimensionsContext } from './Chart';\nimport { LineChartPathContext } from './ChartPath';\nimport useAnimatedPath from './useAnimatedPath';\n\nconst AnimatedPath = Animated.createAnimatedComponent(Path);\n\nexport type LineChartGradientProps = Animated.AnimateProps<PathProps> & {\n color?: string;\n children?: React.ReactNode;\n};\n\nlet id = 0;\n\nLineChartGradient.displayName = 'LineChartGradient';\n\nexport function LineChartGradient({\n color: overrideColor = undefined,\n children,\n ...props\n}: LineChartGradientProps) {\n const { area } = React.useContext(LineChartDimensionsContext);\n const { color: contextColor, isTransitionEnabled } =\n React.useContext(LineChartPathContext);\n\n const color = overrideColor || contextColor;\n\n ////////////////////////////////////////////////\n\n const { animatedProps } = useAnimatedPath({\n enabled: isTransitionEnabled,\n path: area,\n });\n\n ////////////////////////////////////////////////\n\n const localId = React.useRef(++id);\n\n ////////////////////////////////////////////////\n\n return (\n <>\n {children ? (\n <Defs>\n <LinearGradient\n id={`${localId.current}`}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n >\n {children}\n </LinearGradient>\n </Defs>\n ) : (\n <Defs>\n <LinearGradient\n id={`${localId.current}`}\n x1=\"0\"\n x2=\"0\"\n y1=\"0\"\n y2=\"100%\"\n >\n <Stop offset=\"20%\" stopColor={color} stopOpacity={0.15} />\n <Stop offset=\"40%\" stopColor={color} stopOpacity={0.05} />\n <Stop offset=\"100%\" stopColor={color} stopOpacity={0} />\n </LinearGradient>\n </Defs>\n )}\n <AnimatedPath\n animatedProps={animatedProps}\n fill={`url(#${localId.current})`}\n {...props}\n />\n </>\n );\n}\n"]}
|
|
@@ -3,47 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = flattenChildren;
|
|
7
6
|
exports.LineChartGroup = LineChartGroup;
|
|
8
7
|
|
|
9
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
9
|
|
|
11
10
|
var _reactNative = require("react-native");
|
|
12
11
|
|
|
12
|
+
var _reactKeyedFlattenChildren = _interopRequireDefault(require("react-keyed-flatten-children"));
|
|
13
|
+
|
|
13
14
|
var _Chart = require("./Chart");
|
|
14
15
|
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
|
|
15
18
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
19
|
|
|
17
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
21
|
|
|
19
|
-
/* Returns React children into an array, flattening fragments.
|
|
20
|
-
|
|
21
|
-
Forked from https://github.com/grrowl/react-keyed-flatten-children/blob/master/index.ts
|
|
22
|
-
*/
|
|
23
|
-
function flattenChildren(children, depth = 0, keys = []) {
|
|
24
|
-
return _react.Children.toArray(children).reduce( // eslint-disable-next-line
|
|
25
|
-
(acc, node, nodeIndex) => {
|
|
26
|
-
if (node.type === _react.default.Fragment) {
|
|
27
|
-
acc.push.apply(acc, flattenChildren(node.props.children, depth + 1, keys.concat(node.key || nodeIndex)));
|
|
28
|
-
} else {
|
|
29
|
-
if ( /*#__PURE__*/(0, _react.isValidElement)(node)) {
|
|
30
|
-
acc.push( /*#__PURE__*/(0, _react.cloneElement)(node, {
|
|
31
|
-
key: keys.concat(String(node.key)).join('.')
|
|
32
|
-
}));
|
|
33
|
-
} else if (typeof node === 'string' || typeof node === 'number') {
|
|
34
|
-
acc.push(node);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return acc;
|
|
39
|
-
}, []);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
22
|
function LineChartGroup({
|
|
43
23
|
children,
|
|
44
24
|
...props
|
|
45
25
|
}) {
|
|
46
|
-
const flatChildren =
|
|
26
|
+
const flatChildren = (0, _reactKeyedFlattenChildren.default)(children);
|
|
47
27
|
|
|
48
28
|
const flatChildrenCount = _react.Children.count(flatChildren);
|
|
49
29
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["Group.tsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["Group.tsx"],"names":["LineChartGroup","children","props","flatChildren","flatChildrenCount","Children","count","map","child","index","isLast","type","LineChart","absolute"],"mappings":";;;;;;;AAAA;;AAEA;;AACA;;AAEA;;;;;;;;AAMO,SAASA,cAAT,CAAwB;AAAEC,EAAAA,QAAF;AAAY,KAAGC;AAAf,CAAxB,EAAuD;AAC5D,QAAMC,YAAY,GAAG,wCAAgBF,QAAhB,CAArB;;AACA,QAAMG,iBAAiB,GAAGC,gBAASC,KAAT,CAAeH,YAAf,CAA1B;;AACA,sBACE,6BAAC,iBAAD,EAAUD,KAAV,EAEGG,gBAASE,GAAT,CAAaJ,YAAb,EAA2B,CAACK,KAAD,EAAaC,KAAb,KAAuB;AACjD,UAAMC,MAAM,GAAGD,KAAK,KAAKL,iBAAiB,GAAG,CAA7C;;AACA,QAAI,CAACM,MAAD,IAAWF,KAAK,CAACG,IAAN,KAAeC,gBAA9B,EAAyC;AACvC,0BAAO,yBAAaJ,KAAb,EAAoB;AACzBK,QAAAA,QAAQ,EAAE;AADe,OAApB,CAAP;AAGD;;AACD,WAAOL,KAAP;AACD,GARA,CAFH,CADF;AAcD","sourcesContent":["import React from 'react';\nimport { ReactNode, Children, cloneElement } from 'react';\nimport { ViewProps, View } from 'react-native';\nimport flattenChildren from 'react-keyed-flatten-children';\n\nimport { LineChart } from './Chart';\n\ntype Props = {\n children: ReactNode;\n} & ViewProps;\n\nexport function LineChartGroup({ children, ...props }: Props) {\n const flatChildren = flattenChildren(children);\n const flatChildrenCount = Children.count(flatChildren);\n return (\n <View {...props}>\n {/* eslint-disable-next-line @typescript-eslint/no-explicit-any */}\n {Children.map(flatChildren, (child: any, index) => {\n const isLast = index === flatChildrenCount - 1;\n if (!isLast && child.type === LineChart) {\n return cloneElement(child, {\n absolute: true,\n });\n }\n return child;\n })}\n </View>\n );\n}\n"]}
|