sextile.viewdata.charting

Series drawn on the block grid.

A cell is two blocks across and three down, so a region of the frame is a bitmap: across = 2 * cells, down = 3 * rows. These turn a run of numbers into such a bitmap, and blocks.block_runs turns that into the mosaic cells a row writer can place. This module does not decide what is being plotted or what colour it is drawn in.

Values arrive as fractions of the height, not as data. 0.0 is the bottom row of blocks and 1.0 the top. Deciding what the top and bottom of a chart mean is the caller’s, and it is the whole of the interesting part: whether a scale starts at zero, whether it is fixed so that two frames can be compared, where a threshold falls.

A value sits at the middle of its share of the width, so that a chart lines up with a column of labels or pictures above it. That leaves half a share blank at each end, which the line fills by running level out to the edges: it is the last thing known, and a line that stopped short would read as data that stopped.

sextile.viewdata.charting.bars(fractions, *, across, down)[source]

Columns standing on the bottom of the region, one to a value.

Each takes its whole share of the width, so the bars touch. That suits a series that is a quantity per interval rather than a level at an instant – there is no gap between one interval and the next.

Parameters:
Return type:

list[list[bool]]

sextile.viewdata.charting.curve(fractions, *, across, down)[source]

Draw a line through evenly spaced values as a bitmap.

Parameters:
  • fractions (Sequence[float | None]) – The values, each a fraction of the height from 0.0 to 1.0, or None for a gap that breaks the line rather than being crossed.

  • across (int) – The bitmap’s width in blocks.

  • down (int) – The bitmap’s height in blocks.

Return type:

list[list[bool]]

Returns:

A down by across grid of lit blocks. One block to a column, so the line joins corner to corner and reads as a line rather than a filled wall. A missing value breaks it: joining across a gap would draw a claim about a point the series says nothing about.