jordibruin / Swift-Charts-Examples

An overview of the different types of charts you can make with Swift Charts
MIT License
1.95k stars 126 forks source link

Weird Redrawing of Chart #99

Open niclego opened 1 year ago

niclego commented 1 year ago

I have been playing around with SingleLineLollipop.swift and noticed this weird redrawing behavior. I set a break point on line 42 and then run the example on my device/sim ( either doesn't matter ). Every time I touch the screen and drag, the break point gets triggered and the app pauses. At first I thought, ok this makes sense, the selectedElement state var updates, and the chart needs to redraw the chartBackground. No problem. But as you can imagine this isn't ideal... for large data sets I noticed there is a delay / animation hitch when the user drags her finger across the chart. So I thought to extract the state var and the chartBackground to a separate view. But no matter how I extract them, the chart ALWAYS redraws. How can I create a view like you have in the chart background that has data about the x value the user is currently touching and have it update without the whole chart updating?