`.chartAngleSelection` doesn't register taps when tapping a `SectorMark`, have to hold down a little bit

I'm using .chartAngleSelection to grab the angle of the taps on a SectorMark. When using .chartAngleSelection, it does not register "fast" taps on the screen. You have to hold your finger on the screen for longer than a tap for it to be registered. I've tried the same code with .chartXSelection and .chartYSelection and there is no tap delay.

I'm not sure if this is because .chartAngleSelection just came out of beta but it definitely impacts UX.

Replies

This seems to be the case with all charts for .chartXSelection and .chartYSelection. Not sure what can be done.... the system .onTapGesture doesn't have this issue so depending on if you need to track the tap location, this might be a solution

Swift Charts allows us to provide a custom gesture for selection by using the chartGesture(_:) modifier.

You can for exemple configure a SpatialTapGesture to get the tap location and update the chart angle value by calling the selectAngleValue(at:) method.

By using the below code, I managed to get rid of the "hold down" behaviour.

.chartGesture { chart in
    SpatialTapGesture()
        .onEnded { event in
            let angle = chart.angle(at: event.location)
            chart.selectAngleValue(at: angle)
        }
}
Add a Comment