Skip to main content

Module axes

Module axes 

Source
Expand description

Axis ticks, labels, titles and the grid for every chart. ratatui places whatever labels it is given, cutting them or running them together on a narrow plot, and draws the axis titles over the plot’s corners. So datui chooses the ticks, draws their labels and marks, and gives each title a row of its own or none.

Ticks fall on nice values: 1, 2 or 5 times a power of ten, or calendar boundaries on a time axis, as many as the space holds (about one label per 15 columns, one per 4 rows). The rule for labels, on every chart: they never touch, two cells between them. A crowded axis first takes a coarser step, then a shorter form of its labels (12.3k, or a date without its year); the ends of a fixed axis stay while anything fits. A title never covers the plot: it is cut to its row, and dropped when the plot has no rows to spare.

Structs§

AxisSpec
One axis: its range, how its ticks are chosen and written, and its title.
Legend
A chart’s legend: a name per series, each in the style its series draws in.
Placed
An axis’s ticks as placed: each labeled tick’s cell and label, and the cells of every major and minor tick.
PlotAxes
A chart’s two axes and how they are drawn.
PlotFrame
Where a chart’s parts sit in its area.
TickSet
A way to tick an axis: where, the minor ticks between, and the labels at each level of detail.
Track
Where an axis’s values land on screen: cells cells from start, each split in sub dots by the marker the plot draws with.

Functions§

cut
text in at most width cells, cut with the ellipsis when longer.
fit_x_labels
The x labels that fit on a row spanning columns span (start, end) under a plot whose columns are track, each with its column: centered under its tick, kept on the row, LABEL_GAP cells from the next. About one label per 15 columns; a coarser step when they crowd, then shorter forms; none at all when even two do not fit.
fit_y_labels
The y labels for a plot whose rows are track, with at most width cells left of its axis: about one per four rows, each on its tick’s row, in the fullest form that fits the width and tells them apart.
resolution
The dots per cell, across and down, of a canvas drawn with marker.

Type Aliases§

TickLabel
A tick’s label at a level of detail, 0 the fullest; None past the shortest.