---
title: "init(data:desiredCount:calendar:)"
framework: charts
role: symbol
role_heading: Initializer
path: "charts/datebins/init(data:desiredcount:calendar:)"
---

# init(data:desiredCount:calendar:)

Automatically determine the bins from data.

## Declaration

```swift
nonisolated init(data: [Date], desiredCount: Int? = nil, calendar: Calendar = .autoupdatingCurrent)
```

## Parameters

- `data`: The given data values.
- `desiredCount`: The desired number of bins for the given data. If nil, infer the number of bins automatically from data using https://doi.org/10.1093/biomet/66.3.605 capped at 200.

## Return Value

Return Value The inferred bins.
