codeandtheory / YCharts

YCharts is a graph library for Android.
Apache License 2.0
604 stars 56 forks source link

Advanced Cubic Bezier algorithm for prettier line charts #150

Open mlnoone opened 11 months ago

mlnoone commented 11 months ago

:loudspeaker: Type of change

:scroll: Description

Modified LineChart to use the Advanced Cubic Bezier algorithm for line smoothening as given at https://medium.com/mobile-app-development-publication/making-graph-plotting-function-in-jetpack-compose-95c80ee6fc7f

:bulb: Motivation and Context

The default line chart has a 'staggered' look which is not found in libs like chart.js or SwiftUI charts, so I searched for ways to improve the smoothening algorithm and found the mentioned article, and tried it out.

:green_heart: How did you test it?

Using the library with the modified file in an Android project as module dependency and tested both on emulator and device

:pencil: Checklist

:camera_flash: Screenshots / GIFs

Basic Cubic Bezier Basic Cubic Bezier

Advancd Cubic Bezier Advance Cubic Bezier

Validation

Run the sample app and check the difference in the Line Charts

Risks

It is computationally more expensive than the basic cubic Bezier