pub fn chart(
style: &PieceStyle,
chart: &Chart<'_>,
bars: &[Bar<'_>],
) -> Vec<Line<'static>>Expand description
A chart, one line per bar.
§Why the bars lie down here
A webview draws a chart as columns standing on an axis, and a terminal has
one glyph per cell and a handful of rows. Standing the bars up would mean
drawing each one as a stack of partial blocks and giving up the labels,
which are the half a reader actually reads. Laid down, every bar keeps its
place on the axis, its magnitude and its reading, and the drawing is
meter’s repeated – which is the honest answer for the same reason
quasi-tui’s timeline draws no gridlines: a terminal draws what a terminal
draws rather than an impression of the other renderer.
The axis is not drawn as a rule or a scale, for that same reason. It is
stated instead: every bar is meter_cells wide and full means
Chart::most, so the widths are comparable across the run, which is the
one thing a chart has to get right.
§What is left out
Chart::label is not drawn. It names what the magnitudes are and every
bar’s own Bar::reading already carries the units, so drawing it would be
a heading this function does not own the room for. A caller that wants it
says it as a heading, which is what a description does anyway.
Labels are padded to the widest, so the bars line up. That is measured in
characters rather than in display cells, which is wrong for a label holding
a wide glyph and is what crate::text would cost to bring in for a case
that has not turned up.