FormidableLabs / victory-native-xl

A charting library for React Native with a focus on performance and customization.
https://commerce.nearform.com/open-source/victory-native
730 stars 54 forks source link

Showing y value in tooltip while dragging #211

Closed ffoton closed 8 months ago

ffoton commented 8 months ago

Hello!

Great library, but one thing is bugging me.

Is the tooltip in the example "stocks-gesture.mp4" from the read-me possible to achieve? More specifically, to show the y-value on tooltip while dragging?

No matter what I do, i just get the initial onPress value, and then the onPressRelease value when releasing.

I have read ticket #176 and tried using Skia text elements, without luck. I also saw ticket #158, but that did not help me either.

I figure that it has to to with useSharedValue running on another thread. But how was it done in the example?

I am using:

    "expo": "~50.0.11",
    "expo-camera": "~14.0.6",
    "expo-constants": "~15.4.5",
    "expo-font": "~11.10.3",
    "expo-linear-gradient": "~12.7.2",
    "expo-linking": "~6.2.2",
    "expo-router": "~3.4.8",
    "expo-secure-store": "^12.8.1",
    "expo-status-bar": "~1.11.1",
    "moti": "^0.28.1",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "react-native": "0.73.4",
    "react-native-gesture-handler": "~2.14.0",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-reanimated": "~3.6.2",
    "react-native-safe-area-context": "4.8.2",
    "react-native-screens": "~3.29.0",
    "react-native-svg": "14.1.0",
    "react-native-web": "~0.19.6",
    "victory-native": "^40.0.4"

I managed to update the text value of a TextInput field, using useAnimatedReaction together with setNativeProps. But it feels like a hack.. And is unstable, sometimes make the iOS emulator to crash.

Am I missing something? Thanks in advance!

ffoton commented 8 months ago

Update:

I found the code from the example here: https://github.com/FormidableLabs/victory-native-xl/blob/main/example/app/stock-price.tsx

So I found the solution there :)