Published release 0.2.1. Unreleased PR #2 reference.
LOOM 0.2.1 / 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)])
_ = Chart(datasets: [dataset])Members on this page
Feature guides and release status
Chart
struct ChartConforms 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.
datasets
var datasets: [ChartDataset]A public field of this type. Its value type and mutability are shown in the declaration.
Source · Chart.swift:100xAxis
var xAxis: ChartAxisA public field of this type. Its value type and mutability are shown in the declaration.
Source · Chart.swift:101yAxis
var yAxis: ChartAxisA public field of this type. Its value type and mutability are shown in the declaration.
Source · Chart.swift:102style
var style: StyleVisual attributes used when painting this value.
Source · Chart.swift:103legendPosition
var legendPosition: ChartLegendPositionA public field of this type. Its value type and mutability are shown in the declaration.
Source · Chart.swift:104legendStyle
var legendStyle: Style?Nil inherits the chart appearance; an explicit style replaces it.
Source · Chart.swift:106init(datasets:xAxis:yAxis:style:)
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.
resolvedXBounds
var resolvedXBounds: CanvasBounds { get }Effective bounds, including constant-range expansion.
Invalid explicit bounds remain invalid.
Source · Chart.swift:121resolvedYBounds
var resolvedYBounds: CanvasBounds { get }A public field of this type. Its value type and mutability are shown in the declaration.
Source · Chart.swift:122plotArea(in:)
func plotArea(in area: Rect) -> RectThe 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.
render(in:buffer:)
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.