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

Feat: Improve createGraphPath function and simplify range logic #62

Closed chrispader closed 1 year ago

chrispader commented 1 year ago

This PR simplifies and improves the logic in createGraphPath and furthermore fixes some small bugs, where the graph might be empty or (almost)flat lines are kinda "wobbly".

Graphs with very few data points

Graphs with very few data points look way smoother now. Before, it might have occurred that lines weren't flat when they should be and vice versa weren't cubic but instead cut-off.

Screenshot 2023-02-17 at 17 03 47

Graphs with range applied

It is now possible to also draw graphs, where the range is smaller then the provided dataset. This could be useful, e.g. if you have data for each day of one year and you only want to show a month without having to reformat data.

There's not a lot that changed for the eye, but behind the back logic around the range prop has improved a lot too.

Screenshot 2023-02-17 at 17 04 05

⚠️ Warning ⚠️

The smoothing prop on the LineGraph component got removed. With the new createGraphPath logic, it is not necessary to change the smoothing manually. This will not break anything, but you can safely remove it from your codebase.