Skip to content

Charts

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) -> Color
legend :: 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 :: struct {
label: string,
color: Color,
}
FieldTypeNotes
labelstring
colorColor

Source: kiln/chart.odin:38

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.

FieldTypeNotes
labelstring
startf64
endf64
segments[]Timeline_Segment

Source: kiln/chart.odin:241

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.

FieldTypeNotes
startf64in the row’s units (ms, minutes, …)
endf64in the row’s units (ms, minutes, …)
colorColor
tooltipstring

Source: kiln/chart.odin:234

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.

ArgumentTypeDefault
values[]f32required
labels[]stringnil
heightf32160
toneToneTone.Primary
formatproc(v: f32) -> stringnil
highlightint-1
highlight_toneToneTone.Info
colors[]Colornil
value_axisboolfalse
ReturnsType
clickedint
okbool

Source: kiln/chart.odin:70

chart_color :: proc(i: int) -> Color

The i-th categorical chart color of the theme (Colors.chart); indices outside 0..7 give a neutral gray, e.g. for “other”.

ArgumentTypeDefault
iintrequired
ReturnsType
#0Color

Source: kiln/chart.odin:18

legend :: proc(items: []Legend_Item)

Swatches with labels that wrap into several lines when there is not enough room.

ArgumentTypeDefault
items[]Legend_Itemrequired

Source: kiln/chart.odin:44

swatch :: proc(color: Color, size := Size.Dot)

A small colored square, e.g. in front of a category name.

ArgumentTypeDefault
colorColorrequired
sizeSizeSize.Dot

Source: kiln/chart.odin:24

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.

ArgumentTypeDefault
rows[]Timeline_Rowrequired
ticks[]stringnil
row_heightf3218
label_widthf3296
ReturnsType
rowint
segmentint
okbool

Source: kiln/chart.odin:254