margelo / react-native-graph

📈 Beautiful, high-performance Graphs and Charts for React Native built with Skia
https://margelo.io
MIT License
2.08k stars 118 forks source link

fix: Remove incorrect delta from pixel factor calculation #56

Closed thomas-coldwell closed 1 year ago

thomas-coldwell commented 1 year ago

This PR fixes an issue identified where some later dates in the points data would cause NaNs in the cubic path calculation. Once I removed the delta value for the pixelFactorX calculation the graph rendered correctly with a valid path.

I'm not fully sure I understand why this fixes it so would be great if you could shed some light here @chrispader and make sure I'm not breaking something else with this change 😄

chrispader commented 1 year ago

I made some improvements to how all of the createGraphPath() logic is working in #52 , but i don't know if this exactly fixes your problem.

I tested your changes with the latest main branch and it seems to be very laggy for me. Not sure yet, what's causing this.

https://user-images.githubusercontent.com/20173411/212394582-1ad55cb7-bf0f-4002-aca8-52d360614315.mp4

chrispader commented 1 year ago

Both the pan gesture as well as initial rendering is very laggy atm, investigating this now. @thomas-coldwell would my mind trying the current changes in main with your project. Maybe the issue is fixed already

thomas-coldwell commented 1 year ago

Hey @chrispader I've tried the latest changes on main, but this still creates NaNs in the cubic path calculation and thus causes no graph to be rendered when using older dates (here's the test dates I'm using if you want to try repro https://github.com/margelo/react-native-graph/pull/56/files#diff-a895e922286dc9ab015822845889d3553db8349679cf1ea63bae81ac3862a068R14-R16):

thomas-coldwell commented 1 year ago

This latest change should fix the drawingFactor calculation. Prior to this change it was creating hundreds of points in-between data points hence the lag when scrubbing over the graph 😄

chrispader commented 1 year ago

Thanks for your help @thomas-coldwell

I definitely have to do some renaming of the variables used for the path calculation. They seem somehow misleading, but for now it looks good