margelo / react-native-graph

📈 Beautiful, high-performance Graphs and Charts for React Native built with Skia

Home Page:https://margelo.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Q: Worklet version of 'getYforX' function

vladyslavNiemtsev opened this issue · comments

Hi! First of all - thanks for your library - it`s really very great solution!

I have a question about 'getYforX' function realisation.
For example in 'react-native-redash', also from William Candillon - this functions is 'worklet'.

https://github.com/wcandillon/react-native-redash/blob/a7d7e88ea8d00e964566f8f0c51abee74d92bdcd/src/Paths.ts#L312

Why didn't you use them also in worklet's maner?

I am calling them from the JS Thread thru Skia, not from a Worklet :)

@mrousavy Thanks for the answer!

Does this mean that these calculations happens in JS Thread instead of native / UI (as it should by using worklets)?

Does this mean that these calculations happens in JS Thread instead of native / UI (as it should by using worklets)?

Worklets still run in JS lol. They are not native, it's all JS - it's just a different Thread. RN Skia runs on JS Thread, so I run the calculations on a JS Thread as well.

Got it. So, basically there is no difference between 'worklet' version of getYforX and yours that runs with Skia?

Could you also, please, give me a shortest answer - why this approach (with using Skia) is more fastest and smother than react-native-svg one?

I know there is also Rainbow chart library (https://github.com/rainbow-me/react-native-animated-charts) tries to do the similar things but used Reanimated and SVG

Yea, Skia just renders faster than SVG. It does not create a lot of unnecessary views and is in general just more performant. Try it out for yourself! :)