考虑到这是一个心率表,我试图使图表的Y最大刻度为210(bpm),例如.chartYScale(domain: 0 ... 210)
.然而,只有当我通过200或300时,它似乎才能正确zoom ,介于两者之间的任何东西都不起作用.这是故意的还是一个bug?
import SwiftUI
import Charts
import HealthKit
struct TestYAxisRangeChart: View {
let heartRateData = [80.0, 90.0, 120.0, 150.0, 160.0, 140.0, 125.0, 110.0, 88.0]
var body: some View {
Chart {
ForEach(heartRateData, id: \.self) { sample in
LineMark(
x: .value("", heartRateData.firstIndex(of: sample)!),
y: .value("HR", sample))
.foregroundStyle(Color.red)
}
}
.chartYAxis{
AxisMarks(position: .leading)
}
.frame(height: 300)
.padding(.horizontal)
.chartYScale(domain: 0 ... 210)
}
}
struct TestYAxisRangeChart_Previews: PreviewProvider {
static var previews: some View {
TestYAxisRangeChart()
}
}