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

Sparkline

One terminal column per sample, with multirow eighth-cell precision and optional missing markers.

Autoscaling considers all finite positive samples, including samples outside the viewport. An explicit nonpositive or non-finite maximum draws no filled cells. Missing markers appear only on the bottom row; invalid missing symbols fall back to a space. Rendering owns no I/O.

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

_ = Sparkline(samples: [2, 4, nil, 8, 3], maximum: 8)
Members on this page

Feature guides and release status

Sparkline

Structure
struct Sparkline

Conforms to: Widget.

One terminal column per sample, with multirow eighth-cell precision and optional missing markers.

Autoscaling considers all finite positive samples, including samples outside the viewport. An explicit nonpositive or non-finite maximum draws no filled cells. Missing markers appear only on the bottom row; invalid missing symbols fall back to a space. Rendering owns no I/O.

Source · Sparkline.swift:45

bars

Instance Property
var bars: [SparklineBar]

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

Source · Sparkline.swift:46

maximum

Instance Property
var maximum: Double?

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

Source · Sparkline.swift:47

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · Sparkline.swift:48

direction

Instance Property
var direction: SparklineDirection

The horizontal or vertical allocation axis.

Source · Sparkline.swift:49

symbols

Instance Property
var symbols: SparklineSymbols

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

Source · Sparkline.swift:50

missingSymbol

Instance Property
var missingSymbol: String

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

Source · Sparkline.swift:51

missingStyle

Instance Property
var missingStyle: StylePatch

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

Source · Sparkline.swift:52

init(_:maximum:style:)

Initializer
init(_ values: [Double], maximum: Double? = nil, style: Style = Style())

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

Parameters (3)
values
Argument type and any default are shown in the declaration; see the behavior notes above.
maximum
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Sparkline.swift:54

init(samples:maximum:style:)

Initializer
init(samples: [Double?], maximum: Double? = nil, style: Style = Style())

Optional samples use a label so Sparkline([]) remains unambiguous.

Parameters (3)
samples
Argument type and any default are shown in the declaration; see the behavior notes above.
maximum
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Sparkline.swift:59

init(bars:maximum:style:)

Initializer
init(bars: [SparklineBar], maximum: Double? = nil, style: Style = Style())

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

Parameters (3)
bars
Argument type and any default are shown in the declaration; see the behavior notes above.
maximum
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Sparkline.swift:63

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 · Sparkline.swift:69