Charts
At a glance
Section titled “At a glance”Legend_Item :: struct {...}Timeline_Row :: struct {...}Timeline_Segment :: struct {...}bar_chart :: proc(values: []f32, labels: []string = nil, height: f32 = 160, tone := Tone.Primary, format: proc(v: f32) -> string = nil, highlight := -1, highlight_tone := Tone.Info, colors: []Color = nil, value_axis := false) -> (clicked: int, ok: bool)chart_color :: proc(i: int) -> Colorlegend :: proc(items: []Legend_Item)swatch :: proc(color: Color, size := Size.Dot)timeline :: proc(rows: []Timeline_Row, ticks: []string = nil, row_height: f32 = 18, label_width: f32 = 96) -> (row, segment: int, ok: bool)Legend_Item
Section titled “Legend_Item”Legend_Item :: struct { label: string, color: Color,}| Field | Type | Notes |
|---|---|---|
label | string | |
color | Color |
Source: kiln/chart.odin:38
Timeline_Row
Section titled “Timeline_Row”Timeline_Row :: struct { label: string, start, end: f64, segments: []Timeline_Segment,}One row of a timeline: a label and segments over the range start .. end.
| Field | Type | Notes |
|---|---|---|
label | string | |
start | f64 | |
end | f64 | |
segments | []Timeline_Segment |
Source: kiln/chart.odin:241
Timeline_Segment
Section titled “Timeline_Segment”Timeline_Segment :: struct { start, end: f64, // in the row's units (ms, minutes, ...) color: Color, tooltip: string,}A colored range in a timeline row, e.g. the time an app was in use.
| Field | Type | Notes |
|---|---|---|
start | f64 | in the row’s units (ms, minutes, …) |
end | f64 | in the row’s units (ms, minutes, …) |
color | Color | |
tooltip | string |
Source: kiln/chart.odin:234
Procedures
Section titled “Procedures”bar_chart
Section titled “bar_chart”bar_chart :: proc( values: []f32, labels: []string = nil, height: f32 = 160, tone := Tone.Primary, format: proc(v: f32) -> string = nil, highlight := -1, highlight_tone := Tone.Info, colors: []Color = nil, value_axis := false,) -> (clicked: int, ok: bool)labels[i] belongs to values[i]; values are drawn relative to the largest one. height is
in units. format writes a value for the tooltip and the axis (default %v). The bar at
highlight (e.g. today) is drawn in highlight_tone; colors gives every bar its own color
and wins over both. value_axis adds three gridlines with values on the left.
if i, ok := kiln.bar_chart(m.minutes, DAYS[:], format = format_minutes, highlight = today); ok { append(out, Select_Day{i})}Returns the index of the clicked bar. clicked, tooltip, … after the chart refer to the
whole chart.
| Argument | Type | Default |
|---|---|---|
values | []f32 | required |
labels | []string | nil |
height | f32 | 160 |
tone | Tone | Tone.Primary |
format | proc(v: f32) -> string | nil |
highlight | int | -1 |
highlight_tone | Tone | Tone.Info |
colors | []Color | nil |
value_axis | bool | false |
| Returns | Type |
|---|---|
clicked | int |
ok | bool |
Source: kiln/chart.odin:70
chart_color
Section titled “chart_color”chart_color :: proc(i: int) -> ColorThe i-th categorical chart color of the theme (Colors.chart); indices outside 0..7 give a
neutral gray, e.g. for “other”.
| Argument | Type | Default |
|---|---|---|
i | int | required |
| Returns | Type |
|---|---|
| #0 | Color |
Source: kiln/chart.odin:18
legend
Section titled “legend”legend :: proc(items: []Legend_Item)Swatches with labels that wrap into several lines when there is not enough room.
| Argument | Type | Default |
|---|---|---|
items | []Legend_Item | required |
Source: kiln/chart.odin:44
swatch
Section titled “swatch”swatch :: proc(color: Color, size := Size.Dot)A small colored square, e.g. in front of a category name.
| Argument | Type | Default |
|---|---|---|
color | Color | required |
size | Size | Size.Dot |
Source: kiln/chart.odin:24
timeline
Section titled “timeline”timeline :: proc( rows: []Timeline_Row, ticks: []string = nil, row_height: f32 = 18, label_width: f32 = 96,) -> (row, segment: int, ok: bool)Rows of colored segments over a common range, e.g. the use of apps over a day. Segments may
overlap (several devices at once). ticks are labels spread evenly below the rows
({"0", "6", "12", "18", "24"}), row_height and label_width are in units.
if r, s, ok := kiln.timeline(rows, HOURS[:]); ok {append(out, Show_Details{r, s})}Returns the clicked row and segment; the segment is -1 when the row label was clicked.
| Argument | Type | Default |
|---|---|---|
rows | []Timeline_Row | required |
ticks | []string | nil |
row_height | f32 | 18 |
label_width | f32 | 96 |
| Returns | Type |
|---|---|
row | int |
segment | int |
ok | bool |
Source: kiln/chart.odin:254