[ad_1]
I am attempting so as to add axis unit labels to a chart constructed with Swift Charts.
For instance:
import SwiftUI
import Charts
struct ContentView: View {
struct ChartData: Identifiable {
var id: Double { xVal }
let xVal: Double
let yVal: Double
}
let knowledge: [ChartData] = [
.init(xVal: -5, yVal: 5),
.init(xVal: 0, yVal: 10),
.init(xVal: 5, yVal: 20),
]
var physique: some View {
Chart(knowledge) {
LineMark(
x: .worth("Place", $0.xVal),
y: .worth("Peak", $0.yVal)
)
}
.chartYAxis {
AxisMarks(place: .main)
}
}
}
Chart output, with the specified labels annotated in pink:

How can we create axis labels like these in pink above – or in any other case add models/descriptions to our axes?
[ad_2]
