In this code I declare a Chart with an x scale domain between two doubles:
Chart(points, id: \.self) { point in
LineMark(
x: .value("time/s", point.timestamp),
y: .value("potential/mV", point.potential)
)
.foregroundStyle(by: .value("Electrode", point.electrode.symbol))
}
.chartXScale(domain: timeWindow)
// ...
where timeWindow
is declared as follows:
var timeWindow: ClosedRange<Double> {
doc.contents.time(at: window.lowerBound)...doc.contents.time(at: window.upperBound)
}
and time
is defined as:
func time(at index: Int) -> Double {
return Double(index) * (1 / sampleRate)
}
However, the chart x-axis this produces does not have a start and end at the lower and upper bounds of the ClosedRange<Double>
I have provided, rather there is a section of mystery space on either the left and right side of the plots:
How can I get the chart to adhere to the domain I have provided (the bounds are also displayed in the text view of the bottomBar ToolbarItemGroup, using the code Text("\(timeWindow.lowerBound.format()) s to \(timeWindow.upperBound.format()) s")
)? And how can I get the y-axis to render on the left of the chart?