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

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 Blaze.

SPONSORED Still waiting on your CI build? Speed it up ~3x with Blaze - change one line, pay less, keep your existing GitHub workflows. First 25 HWS readers to use code HACKING at checkout get 50% off the first year. Try it now for free!

Reserve your 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.