<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Charts",
  "identifier" : "/documentation/Charts/AreaPlot/init(x:y:domain:function:)-2fab1",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Charts",
      "Charts"
    ],
    "preciseIdentifier" : "s:6Charts8AreaPlotVA2A08FunctionbC7ContentVRszlE1x1y6domain8functionACyAEG7SwiftUI4TextV_AMSNySdGSgS2dYbctcfc"
  },
  "title" : "init(x:y:domain:function:)"
}
-->

# init(x:y:domain:function:)

Creates a mark that fills the area between zero and the given function.

```
nonisolated init(x: Text, y: Text, domain: ClosedRange<Double>? = nil, function: @escaping @Sendable (Double) -> Double)
```

## Discussion

Parameters:

- x: The localized string key for the x label.
- y: The localized string key for the y label.
- domain: The domain of x. If set to `nil`, the domain of the chart’s x scale will be used.
- function: The function to graph..

> Note: For x values where the function is undefined or is infinity, the function is expected to return `Double.nan` or `Double.infinity` respectively.

---

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)