📊
SwiftChartsの .value()の第一引数が使われる様子
SwiftChartsの .value() の第一引数が何に使われるかよくわからなかったので確かめました。
import SwiftUI
import Charts
struct ContentView: View {
struct A: Identifiable {
var id: String {
name
}
let name: String
let score: Int
}
let subjects: [A] = [
A(name: "Suzuki", score: 3),
A(name: "Sato", score: 4),
A(name: "Takahashi", score: 5)]
var body: some View {
Chart(subjects, id: \.name) { element in
BarMark(
x: .value("name", element.name),
y: .value("score", element.score)
)
}
.frame(height: 200.0)
.padding()
}
}
操作は VoiceOverをOnにして
- 左の要素を選択
- 中央の要素を選択
- 右の要素を選択
- Chartの詳細を読み上げ
です。
the X axis is name
the Y axis is score
there's one data series
と読み上げています。(冠詞の間違いなどがあるかもしれませんが。)
Voice Overの操作
Discussion