---
title: "init(x:y:domain:function:)"
framework: charts
role: symbol
role_heading: Initializer
path: "charts/lineplot/init(x:y:domain:function:)-17i43"
---

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

Creates a mark that graphs a function y = f(x).

## Declaration

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

## Discussion

Discussion Parameters: x: The x label. y: 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.

## See Also

### Plotting functions

- [init(x:y:domain:function:)](charts/lineplot/init(x:y:domain:function:)-6m9gg.md)
- [init(x:y:domain:function:)](charts/lineplot/init(x:y:domain:function:)-1135f.md)
- [init(x:y:domain:function:)](charts/lineplot/init(x:y:domain:function:)-6gv5v.md)
