Skip to main content

Module table

Module table 

Source
Expand description

The table every app shows data in: plain columns in (numbers or text, no data-frame library), a header, a column summary that folds down between the header and the rows, and the rows as a virtual list (only those on screen are made).

  • Header: per column a type mark (# numbers, Aa text), its name, its unit, the sort mark and, when the app gives roles, a role tag. A click on the name sorts (ascending, descending, off); a click on the tag is the app’s (TableEvent::RoleClicked). Drag a header’s right edge to resize, double-click it to fit again.
  • Summary (folds down, giving its height back to the rows): missing and unique; numbers draw a histogram with their minimum and maximum, text its most common values with their share (or one count when there are many). A click selects the column (TableEvent::Selected).
  • Rows: one line each, values in mono, numbers to the right; the header and the summary follow the rows sideways.
  • Columns fill the pane: each starts at TableSpec::min_column_width and the spare width is shared out among those not resized by hand.
  • Text never overflows: every cell, name and value is one line ending in “…”; a header’s full name, unit and type are in its tooltip.

Options, each off by default (TableOptions, TableView::with_options):

  • Row marks: a colour per row given by the app (TableView::set_row_colors), a dot before the first column (a unit’s colour in the plots).
  • Toolbar line: a filter menu on one text column (“All labels ▾”) and the row and selection counts (“279 units · 1 selected”); TableEvent::FilterChanged.
  • Selection of rows, single or multiple (click; shift for a range; ctrl or cmd to add or remove one), reported as TableEvent::RowsSelected.
  • Bar cells: a number column drawn as a bar over its range inside each cell, in the row’s colour or the accent (Column::bar).
  • Compact: no header, no summary, no row numbers, the columns sharing the width (a side list such as “Similar units”).
  • Summary per table: open, folded or off (SummaryStart); off computes none.
  • Theming (TableStyle, its default from the app’s theme): density, stripes or grid lines, header style, numbers in mono or not, selection and hover colours, bar colour.

Summaries, sorting and the filter are computed off the UI thread (summarize, sort_order, view_order: plain functions, for tests and for apps that compute them elsewhere). TableSpec is the widget’s settings as JSON (the same keys as the design prototype).

The table takes plain columns; a kitchen-table table becomes them with the kitchen-table feature (TableData::from_table).

Structs§

Column
A column: its name, unit and values.
ColumnSummary
A column’s summary.
CpuSummarizer
Summaries on the CPU, in this thread.
TableData
A table: its name (shown by the app, not the widget) and its columns, all as long.
TableOptions
What a table offers beyond its rows; the default is the plain table (header, open summary, row numbers, no selection).
TableSpec
The widget’s settings; JSON with these keys (each optional: the defaults below).
TableStyle
How a table looks. The default follows the app’s theme: colours left None are the theme’s tokens when drawn (so a switch of theme or accent follows).
TableView
The table view.
Toolbar
The toolbar line: a filter menu on one text column and the row and selection counts.

Enums§

BarColor
What colour bar cells take.
BarRange
The range a bar cell spans.
Density
How tall rows are.
HeaderStyle
How the header looks.
Lines
The lines between rows and cells.
Selection
Which rows a click selects.
Shape
What a column’s summary draws.
SummaryStart
Whether a table has the summary, and how it starts.
TableEvent
What the table tells the app.
Values
One column’s values, one per row (None: missing).

Traits§

Summarizer
Where a table’s summaries are computed: on the CPU here by default (CpuSummarizer), or by a backend the app plugs in (TableView::with_summarizer): a GPU histogram through kitchen-compute, a data-frame library, a server that already holds the table. A backend may replace only Summarizer::histogram (the costly part for numbers) or the whole Summarizer::summarize. Called off the UI thread.

Functions§

click_selection
The rows selected after a click on the row shown at pos of order (shift: the range from anchor; toggle: ctrl or cmd, add or remove the row). Returns the selection and the new anchor.
cpu_histogram
The CPU histogram Summarizer::histogram defaults to.
distinct_text
The distinct values of text column col, sorted (the toolbar’s menu).
sort_order
The rows in order of column col (missing values last, ties in table order).
summarize
Every column’s summary on the CPU (blocking: run it off the UI thread for a large table).
summarize_column
A column’s summary, its histogram from by.
table
The view’s own entity, made for data (convenience for apps).
view_order
The rows a view shows, in order: sorted by sort ((column, ascending), as sort_order), keeping only those whose text column only.0 reads only.1 (the toolbar’s filter). None when neither is asked: every row, in table order.