ScaleDomain
A type that you can use to configure the domain of a chart.
Declaration
protocol ScaleDomainOverview
A type you use to configure the domain of a chart scale.
Including zero in number scales
By default, number scales include zero in the domain to ensure charts follow the best practice to include a zero baseline in bar charts.
[Image]
For other marks, this zero baseline isn’t as important, but the framework includes zero by default so the domain inference logic is consistent and deterministic. Changing the mark type won’t suddenly affect scale domain.
[Image]
If you don’t want to include the zero baseline in certain cases, use automatic(includeszero:reversed:) to customize the scale domain and disable the automatic zero inclusion.
Chart([20, 30, 50, 70, 85], id: \.self) {
PointMark(
x: .value("Value", $0)
)
}
.chartXScale(domain: .automatic(includesZero: false))[Image]
Reversing the order of inferred domain
You can also reverse the order of the inferred domain:
Chart([20, 30, 50, 70, 85], id: \.self) {
PointMark(
x: .value("Value", $0)
)
}
.chartXScale(domain: .automatic(reversed: true))[Image]