loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / PLOTTING AND CALENDARS

BarChart

Grouped fractional bars in terminal cells, with caller-supplied labels and appearance.

Vertical bars grow upward and reserve bottom rows for nonempty bar/group labels. Horizontal bars grow rightward, reserve a shared left label gutter, and place group labels above their bars. Values are drawn inside bars at the baseline or left edge. Bar width is columns for vertical charts and rows for horizontal charts; gaps are nonnegative. Labels and values use one unwrapped row and clip at whole graphemes. Empty groups consume no space. Negative and non-finite data render as zero.

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

_ = BarChart(groups: [BarGroup([Bar(12, label: "GET"), Bar(7, label: "POST")], label: "API")])
Members on this page

Feature guides and release status

BarChart

Structure
struct BarChart

Conforms to: Widget.

Grouped fractional bars in terminal cells, with caller-supplied labels and appearance.

Vertical bars grow upward and reserve bottom rows for nonempty bar/group labels. Horizontal bars grow rightward, reserve a shared left label gutter, and place group labels above their bars. Values are drawn inside bars at the baseline or left edge. Bar width is columns for vertical charts and rows for horizontal charts; gaps are nonnegative. Labels and values use one unwrapped row and clip at whole graphemes. Empty groups consume no space. Negative and non-finite data render as zero.

Source · BarChart.swift:69

groups

Instance Property
var groups: [BarGroup]

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

Source · BarChart.swift:70

direction

Instance Property
var direction: Direction

The horizontal or vertical allocation axis.

Source · BarChart.swift:71

barWidth

Instance Property
var barWidth: Int

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

Source · BarChart.swift:72

barGap

Instance Property
var barGap: Int

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

Source · BarChart.swift:73

groupGap

Instance Property
var groupGap: Int

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

Source · BarChart.swift:74

maximum

Instance Property
var maximum: Double?

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

Source · BarChart.swift:75

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · BarChart.swift:76

barStyle

Instance Property
var barStyle: Style?

Optional complete replacement styles; nil inherits the chart or resolved bar appearance.

Source · BarChart.swift:78

labelStyle

Instance Property
var labelStyle: Style?

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

Source · BarChart.swift:79

groupLabelStyle

Instance Property
var groupLabelStyle: Style?

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

Source · BarChart.swift:80

valueStyle

Instance Property
var valueStyle: Style?

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

Source · BarChart.swift:81

showsValues

Instance Property
var showsValues: Bool

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

Source · BarChart.swift:82

init(groups:maximum:)

Initializer
init(groups: [BarGroup], maximum: Double? = nil)

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

Parameters (2)
groups
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.
Source · BarChart.swift:84

init(bars:maximum:)

Initializer
init(bars: [Bar], maximum: Double? = nil)

Places ungrouped bars in a single group without a group label.

Parameters (2)
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.
Source · BarChart.swift:90

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 · BarChart.swift:94