<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Charts",
  "identifier" : "/documentation/Charts/ScaleDomain",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "Swift Charts"
    ],
    "preciseIdentifier" : "s:6Charts11ScaleDomainP"
  },
  "title" : "ScaleDomain"
}
-->

# ScaleDomain

A type that you can use to configure the domain of a chart.

```
protocol ScaleDomain
```

## Overview

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.

![Horizontal bar chart with y-axis showing categories A, B, and C and x-axis ranging from 0 to 15. There are three bars: A 5, B 10, C 15.](images/com.apple.Charts/Scales.ChartWithDefaultCategoryDomain@2x.png)

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.

![Horizontal dot plot with x-axis ranging from 0 to 100. It has 5 dots, at 12, 20, 50, 70, and 85.](images/com.apple.Charts/ExNumberScale@2x.png)

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.

```swift
Chart([20, 30, 50, 70, 85], id: \.self) {
    PointMark(
        x: .value("Value", $0)
    )
}
.chartXScale(domain: .automatic(includesZero: false))
```

![Horizontal dot plot with x-axis ranging from 20 to 100. It has 5 dots, at 20, 30, 50, 70, and 85.](images/com.apple.Charts/ScaleDomain.ChartWithNumberScaleExcludingZero@2x.png)

## Reversing the order of inferred domain

You can also reverse the order of the inferred domain:

```swift
Chart([20, 30, 50, 70, 85], id: \.self) {
    PointMark(
        x: .value("Value", $0)
    )
}
.chartXScale(domain: .automatic(reversed: true))
```

![Horizontal dot plot with x-axis ranging from 100 to 0. It has 5 dots, at 85, 70, 50, 30, and 20.](images/com.apple.Charts/ScaleDomain.ChartWithNumberScaleReversed@2x.png)

## Topics

### Type Properties

[`static var automatic: AutomaticScaleDomain`](/documentation/Charts/ScaleDomain/automatic)

Creates a scale domain configuration that infers the scale domain from
data.

### Type Methods

[`static func automatic(includesZero: Bool?, reversed: Bool?) -> AutomaticScaleDomain`](/documentation/Charts/ScaleDomain/automatic(includesZero:reversed:))

Creates a scale domain configuration that infers the scale domain from
data.

[`static func automatic<DataValue>(includesZero: Bool?, reversed: Bool?, dataType: DataValue.Type, modifyInferredDomain: (inout [DataValue]) -> Void) -> AutomaticScaleDomain`](/documentation/Charts/ScaleDomain/automatic(includesZero:reversed:dataType:modifyInferredDomain:))

Creates a scale domain configuration that infers the scale domain from data.

## Relationships

### Conforming Types

[`AutomaticScaleDomain`](/documentation/Charts/AutomaticScaleDomain)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)