Expand description
Zero-dependency terminal chart rendering for trajectory --plot (MBA-1320).
Presentation code shared by the native CLI and the WASM terminal (MBA-1337 p3
moved it from a main.rs-local mod into the lib so wasm.rs can render the
same charts). It stays dependency-free; bindings consumers can simply ignore it.
Two canvas backends share one dot-addressed API (new, width_dots/height_dots,
set, render):
BrailleCanvaspacks a 2 (wide) x 4 (tall) grid of dots into a single Unicode Braille Patterns character (U+2800..=U+28FF), giving roughly 2x the horizontal and 4x the vertical resolution of one terminal character cell.AsciiCanvasuses the same 2x4 dot-per-cell addressing so callers (in particularrender_chart) don’t need to special-case it, but collapses each cell to a single'*'(any dot set) or' '(no dots set) — for terminals/fonts without braille glyph coverage.
Deliberately monochrome: no ANSI color/SGR codes appear anywhere in this module. That
sidesteps NO_COLOR (https://no-color.org/) entirely — there is nothing to suppress —
and keeps output byte-identical whether the terminal honors color, redirects to a file,
or is a dumb pipe. Multiple series plotted on one canvas are therefore visually
indistinguishable where their dots overlap; render_chart lists every series label in
the frame instead of color-coding them. Callers that need series to stay visually
separable should render one series per chart (which is what trajectory --plot does:
one chart for drop, one for lateral drift).
Structs§
- Ascii
Canvas - ASCII fallback canvas: the same dot-addressed API as
BrailleCanvas(a 2x4 dot grid per character cell), but rendered with a single'*'whenever ANY dot in the cell is set,' 'otherwise — for terminals/fonts without braille glyph coverage. - Braille
Canvas - Braille-dot terminal canvas: each character cell packs a 2x4 grid of dots into one Unicode Braille Patterns codepoint.
Enums§
- Canvas
Style - Which canvas backend
render_chartshould use.
Functions§
- render_
chart - Render one or more named
(label, points)series into a single framed chart.