loom & weft
Made for Swift.

Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.

LOOM Unreleased (PR #2) / PLOTTING AND CALENDARS

Chart

A stateless chart with independently styled datasets, axes, custom ticks, and an optional legend.

Axes use terminal-cell geometry. Data drawing is clipped to plotArea(in:) and the caller's clip. Datasets paint in input order; later datasets replace a shared terminal cell, including its marker dots. Dataset styles compose enabled modifiers and explicit colors over the chart style. Axis and legend styles inherit only when nil; an explicit style replaces the inherited appearance. Custom tick labels retain input order; labels colliding with an earlier label are omitted.

Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.

Example

let dataset = ChartDataset(name: "load", points: [CanvasPoint(x: 0, y: 1), CanvasPoint(x: 1, y: 3)], graphType: .filledLine, marker: .quadrant, baseline: 0)
var chart = Chart(datasets: [dataset])
chart.legendPosition = .bottom
chart.legendWidthLimit = .ratio(0.5)
Members on this page

Feature guides and release status

Chart

Structure
struct Chart

Conforms to: Swift.Sendable, Swift.SendableMetatype, Widget.

A stateless chart with independently styled datasets, axes, custom ticks, and an optional legend.

Axes use terminal-cell geometry. Data drawing is clipped to plotArea(in:) and the caller's clip. Datasets paint in input order; later datasets replace a shared terminal cell, including its marker dots. Dataset styles compose enabled modifiers and explicit colors over the chart style. Axis and legend styles inherit only when nil; an explicit style replaces the inherited appearance. Custom tick labels retain input order; labels colliding with an earlier label are omitted.

Source · Chart.swift:130

datasets

Instance Property
var datasets: [ChartDataset]

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Chart.swift:131

xAxis

Instance Property
var xAxis: ChartAxis

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Chart.swift:132

yAxis

Instance Property
var yAxis: ChartAxis

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Chart.swift:133

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · Chart.swift:134

legendPosition

Instance Property
var legendPosition: ChartLegendPosition

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Chart.swift:135

legendWidthLimit

Instance Property
var legendWidthLimit: ChartLegendLimit

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Chart.swift:136

legendHeightLimit

Instance Property
var legendHeightLimit: ChartLegendLimit

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Chart.swift:137

legendStyle

Instance Property
var legendStyle: Style?

Nil inherits the chart appearance; an explicit style replaces it.

Source · Chart.swift:139

init(datasets:xAxis:yAxis:style:)

Initializer
init(datasets: [ChartDataset], xAxis: ChartAxis = ChartAxis(), yAxis: ChartAxis = ChartAxis(), style: Style = Style())

Creates a value with the supplied arguments. Default arguments are shown in the declaration.

Parameters (4)
datasets
Argument type and any default are shown in the declaration; see the behavior notes above.
xAxis
Argument type and any default are shown in the declaration; see the behavior notes above.
yAxis
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Chart.swift:141

resolvedXBounds

Instance Property
var resolvedXBounds: CanvasBounds { get }

Effective bounds, including constant-range expansion.

Invalid explicit bounds remain invalid.

Source · Chart.swift:154

resolvedYBounds

Instance Property
var resolvedYBounds: CanvasBounds { get }

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Chart.swift:155

plotArea(in:)

Instance Method
func plotArea(in area: Rect) -> Rect

The exact data viewport after titles, axes, and custom labels reserve terminal cells.

Tiny areas clamp reservations to leave zero-sized rather than negative regions.

Parameters (1)
in
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns Rect.

Source · Chart.swift:160

render(in:buffer:)

Instance Method
func render(in area: Rect, buffer: inout Buffer)

Paints this widget into the assigned terminal-cell rectangle. Application code owns state, input routing, and terminal lifetime.

Parameters (2)
in
Argument type and any default are shown in the declaration; see the behavior notes above.
buffer
Mutable destination cell grid.
Source · Chart.swift:172