margelo / react-native-graph

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

Chart doesn't appear when all values are the same #28

Closed dynamichny closed 2 years ago

dynamichny commented 2 years ago

As said in the title, all the values can be the same, and the chart won't show - the cause is simple - in createGraphPath there is an issue in getting y value for certain x

const y = height -  ((value - minValue) / (maxValue - minValue)) 
         * innerHeight - graphPadding

so if the value is 5 all the way then it's height - ((5 - 5) / (5 - 5)) * anything and it will give as NaN