Chart
A shot drawn as lines: pressure, temperature, flow and weight against time.
HTML
<div class="bm-stage">
<section class="bm-tile" style="width:680px">
<div class="bm-tile__head"><h2 class="bm-sub">Last shot</h2><span class="bm-rowx" style="gap:var(--space-2)"><span class="bm-chip"><span data-chart-key="pressure"></span>Pressure</span><span class="bm-chip"><span data-chart-key="temperature"></span>Temp</span><span class="bm-chip"><span data-chart-key="flow"></span>Flow</span><span class="bm-chip"><span data-chart-key="weight"></span>Weight</span></span></div>
<div data-chart='{"label": "Pressure, temperature, flow and weight over a 30 second shot. Final values: 9.0 bar, 93 degrees, 2.1 millilitres a second, 36.1 grams.", "h": 240, "x": {"max": 30, "ticks": [0, 10, 20, 30], "unit": "s"}, "y": {"max": 12, "ticks": [0, 4, 8, 12]}, "series": [{"key": "temperature", "max": 120, "unit": "\u00b0", "digits": 0, "points": [[0, 92], [6, 91], [12, 93], [30, 93]]}, {"key": "pressure", "unit": " bar", "points": [[0, 0.2], [3, 1.4], [6, 2.0], [8, 2.2], [11, 5.5], [14, 8.4], [17, 9.1], [24, 9.1], [30, 9.0]]}, {"key": "weight", "max": 48, "unit": " g", "points": [[0, 0], [8, 0.4], [12, 4.0], [18, 14.5], [24, 26.0], [30, 36.1]]}, {"key": "flow", "max": 6, "unit": " ml/s", "points": [[0, 0], [5, 0.3], [9, 0.9], [13, 1.6], [17, 2.0], [24, 2.1], [30, 2.1]]}]}'></div>
</section>
<section class="bm-tile" style="width:296px">
<div class="bm-tile__head"><h2 class="bm-sub">Last shot</h2><span class="bm-chip">30.2 s</span></div>
<div data-chart='{"label": "Pressure, temperature, flow and weight over a 30 second shot. Final values: 9.0 bar, 93 degrees, 2.1 millilitres a second, 36.1 grams.", "h": 200, "x": {"max": 30, "ticks": [0, 10, 20, 30], "unit": "s"}, "y": {"max": 12, "ticks": [0, 4, 8, 12]}, "series": [{"key": "temperature", "max": 120, "unit": "\u00b0", "digits": 0, "points": [[0, 92], [6, 91], [12, 93], [30, 93]]}, {"key": "pressure", "unit": " bar", "points": [[0, 0.2], [3, 1.4], [6, 2.0], [8, 2.2], [11, 5.5], [14, 8.4], [17, 9.1], [24, 9.1], [30, 9.0]]}, {"key": "weight", "max": 48, "unit": " g", "points": [[0, 0], [8, 0.4], [12, 4.0], [18, 14.5], [24, 26.0], [30, 36.1]]}, {"key": "flow", "max": 6, "unit": " ml/s", "points": [[0, 0], [5, 0.3], [9, 0.9], [13, 1.6], [17, 2.0], [24, 2.1], [30, 2.1]]}]}'></div>
</section>
</div>- Lines only: no fill under a line, no points, no animation. A live chart appends points; it never redraws its history.
- Each series differs in three ways, so none depends on hue: its token, its line and its end label.
| Series | Token | Line | End label |
|---|---|---|---|
| Pressure | series-pressure | solid, 2.5 px | 9.0 bar |
| Temperature | series-temperature | solid, 2 px | 93° |
| Flow | series-flow | dashed 6 4, 2 px | 2.1 ml/s |
| Weight | series-weight | dotted 1 5, round caps, 2 px | 36.1 g |
- In every theme the four colours also step in lightness, 1.28:1 or more between neighbours, so they separate in greyscale and for colour-blind readers.
- Label each line at its right end with its last value and unit, in
dataandink. The unit names the series. Labels keep 16 px apart; the chart nudges them when lines end close together. - Add the legend only when the chart is wider than 480 px: neutral Chips, each with a sample of its line (
data-chart-key), not a dot. - Draw charts on
surface-1orsurface-0. Never in a cell: pressure is 2.6:1 onsurface-2in Dark.
Anatomy
BetterMate.chart(options) returns one SVG, drawn at the pixel width you give it so the type stays at data size. A 30 px gutter on the left holds the scale, 76 px on the right holds the end labels, and the grid is three or four horizontal lines in chart-grid with no vertical ones. The left scale belongs to pressure. Any series with its own max is scaled to that and read from its end label.
States
| State | Drawing |
|---|---|
| Live | Lines grow to the right; end labels follow the newest point. Update at most 4 times a second. |
| No shot yet | The grid and scale with no lines, and an EmptyState sentence under the tile's title. |
| A series is missing (no scale, no pressure sensor) | Leave its line, legend Chip and label out. Do not draw a flat line at zero. |
Content
- Time on the x axis in seconds, the unit on the first tick only:
0 s,10,20,30. - At most four series. Compare two shots in two charts, not eight lines.
- Minimum width 240 px. Below 480 px drop the legend; the end labels are enough.
Screen reader
The SVG is role="img". Its aria-label names the series, the span of time and the final values: "Pressure, temperature, flow and weight over a 30 second shot. Final values: 9.0 bar, 93 degrees, 2.1 millilitres a second, 36.1 grams." The same facts stand as text in the ListRow or StatTiles beside it, so nothing lives in the chart alone.
Markup: with BetterMate.hydrate(), which draws at the element's width; or BetterMate.chart({w, h, label, x, y, series}).