pub struct Chart<'a> {
pub most: usize,
pub label: Option<&'a str>,
pub tone: Tone,
}Expand description
A run of magnitudes read against one axis.
Meter is one proportion; this is a series of them that share a maximum,
and the shared maximum is the whole difference. A run of meters draws each
bar against its own total, so a chart said that way states the axis once
per bar and nothing holds the copies together. Here the axis is stated once
and a bar carries only where it sits on it.
§Why the axis and not a percentage per bar
Meter’s reason, one layer out. The app that drew MNW’s revenue chart
computed revenue / most * 100.0 and put the percentage in the markup, and
what reached the reader was a width with no numbers behind it: a bar at 100%
because it is the largest and a bar at 100% because the axis is wrong are the
same width and are not the same fact. Carrying both integers keeps the fact,
and Bar::fraction is one call away for a renderer that wants the ratio.
It is also the only shape that survives a compiled template. A residual holds
numbers the description HANDS a renderer, never ones a renderer works out
from two of them, so a chart drawn from a supplied percentage could be
described and could not be compiled. See quasi_router::stage::number_at.
§What is worded here and what is not
Bar::at is where the bar sits on the axis and label is
what the magnitudes are, which is Meter::label’s split exactly. What
differs is Bar::reading and Bar::note: both arrive already worded,
because a magnitude’s own units are the app’s (“$42.10”, not 4210) and a
count’s noun inflects (“1 sale”, “3 sales”). A renderer that pluralised
would be growing a lexer for one language.
Fields§
§most: usizeThe magnitude the axis runs to. Every bar is read against this.
Zero means there is no axis, not that every bar is full. A renderer draws
nothing rather than dividing by it; see is_empty.
usize because that is what a description counts in – a pager’s offset
and page size are the same – and because it is the only width
quasi_router::stage::number_at has a stand-in for, which is what lets a
chart reach a compiled template at all.
label: Option<&'a str>What the magnitudes are: “revenue”, “plays”.
The noun, not the unit and not the ratio. The unit is already in each
Bar::reading, where it belongs, because only the app knows it.
tone: ToneWhat the axis means, where it means anything.