GO FURTHER, FASTER: Try the Swift Career Accelerator today! >>

iOS 16 Charts and interactivity

Forums > SwiftUI

Hey all,

I'm wondering if anyone has taken a crack at using the new Charts API and adding interaction? I used to have a custom chart that looked like the linked image, whereby you can drag across and the line marks would be "selected" depending where you drag. Current-state, the new Charts API doesn't appear to have any out of the box interactivity I can see.. unless I've missed it.

Has anyone tried anything similar? Using GeometryReader and the like to determine the drag position feels clunky :/

2      

It does. Check Swift Chart Examples as a starting point. I've successfully implemented interactivity with Swift Charts in my app.

2      

Thanks. Looks like the special sauce is SpatialTapGesture .. ideal

2      

UPDATE: I got this working using native Charts, albeit performance of the drag gesture is pretty rough around the edges (completely custom, there is 100% no out of the box Chart stuff here for the drag interaction). Seeing what I can do.

2      

Hacking with Swift is sponsored by RevenueCat.

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

Click to save your free spot now

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.