TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

Zooming in and Out gesture on a chart's X-axis

Forums > SwiftUI

Hello, I've been trying to figure out how to go about using a zoom in/out gesture on Charts in swiftUI. More specifically, I have a linebar chart with dates on the x-axis and I would like the user to be able to use the zoom in/out gesture to zoom in from years to months, days, hours and then be able to zoom back out.

I was experimenting by using the .chartXScale(domain:) modifier along with the .chartXSelection(range: ) modifier with an .onchange(of:) watching the binding state variable of the chartXSelection. The chart would zoom in but it would do so way too quickly and the I couldn't zoom back out. I know that there is a github example out there that does this for Doubles (not dates).

Can someone point me in the right direction of how I could achieve this functionality?

3      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.