Post

Replies

Boosts

Views

Activity

Swift Charts Accessibility Grouping
SwiftUI Charts automatically groups accessibility elements on the graph (Double / Date for example) when there's a lot of data, which overrides the accessibilityLabel and value I set for each data point. This makes sense, but how do we modify the chart navigation accessibility readout when this grouping occurs? Here's an example: var body: some View { let salesData: [(Date, Double)] = [ (Date().addingTimeInterval(-1 * 24 * 60 * 60), 1200), (Date().addingTimeInterval(-2 * 24 * 60 * 60), 1500), (Date().addingTimeInterval(-3 * 24 * 60 * 60), 1000), (Date().addingTimeInterval(-4 * 24 * 60 * 60), 500), (Date().addingTimeInterval(-5 * 24 * 60 * 60), 1500), (Date().addingTimeInterval(-6 * 24 * 60 * 60), 1400), (Date().addingTimeInterval(-7 * 24 * 60 * 60), 1300), (Date().addingTimeInterval(-8 * 24 * 60 * 60), 1800), (Date().addingTimeInterval(-9 * 24 * 60 * 60), 500), (Date().addingTimeInterval(-10 * 24 * 60 * 60), 800), (Date().addingTimeInterval(-11 * 24 * 60 * 60), 800), (Date().addingTimeInterval(-12 * 24 * 60 * 60), 1000), (Date().addingTimeInterval(-13 * 24 * 60 * 60), 1500), (Date().addingTimeInterval(-14 * 24 * 60 * 60), 1500), (Date().addingTimeInterval(-15 * 24 * 60 * 60), 900), ] Chart { ForEach(salesData, id: \.0) { date, sales in LineMark( x: .value("Foo", date), y: .value("Bar", sales) ).accessibilityLabel("Foo: \(date.formatted(date: .abbreviated, time: .omitted)) Bar: \(sales.formatted(.currency(code: "USD")))") } } .accessibilityElement(children: .contain) } } I am wondering if there's a protocol, modifier.. or maybe something like UIAccessibilityContainerType.
2
3
588
Aug ’24