I was trying out the Audio Graph APIs. I'm trying to add gridlines to my chart's data axes descriptor, but doing so doesn't seem to make any difference to me. So I'm surely missing something...
I was watching the WWDC21 session "Bring accessibility to charts in your app", and the presenter says: "When you provide grid lines, they're represented in the audio graph as haptic feedback during playback and interaction." And that is quite interesting!
This is how I'm trying to do it.
var accessibilityChartDescriptor: AXChartDescriptor? {
get {
let xAxis = AXNumericDataAxisDescriptor(title: "Lines of code", range: 0...10, gridlinePositions: []) { number in
"\(number) lines"
}
let yAxis = AXNumericDataAxisDescriptor(title: "Lines of code", range: 0...40, gridlinePositions: []) { number in
"\(number) cups"
}
let dataSeriesDescriptor = AXDataSeriesDescriptor(name: "Lines of code per coffees taken", isContinuous: false, dataPoints: [20, 30, 35, 32, 28, 9, 4, 3, 15, 1].enumerated().map({ (point, index) in
AXDataPoint(x: Double(point), y: Double(index), additionalValues: [], label: nil)
}))
return AXChartDescriptor(title: "Cups of coffee vs. lines of code", summary: "This chart shows how coffee consumption impacts coding ability", xAxis: xAxis, yAxis: yAxis, additionalAxes: [], series: [dataSeriesDescriptor])
}
set {}
}
But for me, it already showed grid lines even if I didn't configure them. Once I do, they don't change visually and it is not adding any haptic feedback... So both configuring gridlines or not, the Chart Detail screen looks like this:
Any pointers on how I can achieve having gridlines that provide haptic feedback would be hugely appreciated! Many thanks!