In this chart I'd like to have control over the number of xAxis labels as well as the placement, however I want the framework to control what is actually in the label, i.e. I don't want custom xAxis labels.
See my code below and the resulting chart.
I would instead like (1) the first date to be on the far left and (2) the last date to not be cut off?
Chart {
ForEach(unwrappedVo2Max) { vo2MaxSample in
AreaMark(
x: .value("Date", vo2MaxSample.startDate),
y: .value("Cardio Fitness", vo2MaxSample.quantity.doubleValue(for: HKUnit(from: "ml/kg*min")))
)
//.interpolationMethod(.cardinal)
.opacity(0.6)
.alignsMarkStylesWithPlotArea()
.foregroundStyle( .linearGradient(
colors: \[Color.clear, TrackerConstants.AppleFitnessPurple\],
startPoint: .bottom, endPoint: .top
))
LineMark(
x: .value("Date", vo2MaxSample.startDate),
y: .value("Cardio Fitness", vo2MaxSample.quantity.doubleValue(for: HKUnit(from: "ml/kg*min")))
)
.lineStyle(StrokeStyle(lineWidth: 2))
.foregroundStyle(TrackerConstants.AppleFitnessPurple)
}
}
.frame(height: TrackerConstants.chartHeight)
.padding(.horizontal)
.chartYScale(domain: SwiftChartHelpers.getYScaleMin(values: unwrappedVo2Max.map { $0.quantity.doubleValue(for: HKUnit(from: "ml/kg*min")) }, padding: 10)...SwiftChartHelpers.getYScaleMax(values: unwrappedVo2Max.map { $0.quantity.doubleValue(for: HKUnit(from: "ml/kg*min")) }, padding: 10.0))
.chartYAxis {
AxisMarks(position: .leading)
}