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 try! Swift Tokyo.

SPONSORED Ready to dive into the world of Swift? try! Swift Tokyo is the premier iOS developer conference will be happened in April 9th-11th, where you can learn from industry experts, connect with fellow developers, and explore the latest in Swift and iOS development. Don’t miss out on this opportunity to level up your skills and be part of the Swift community!

Get your ticket here

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.