Chart
Something measured repeatedly, drawn against time — the workhorse chart: MOS per trunk, latency per site, calls per minute.
{/* Generated by scripts/build-component-docs.mjs — do not edit. The source is the component folder: guidance.json, the doc block and the props. Change those. */}
Something measured repeatedly, drawn against time — the workhorse chart: MOS per trunk, latency per site, calls per minute.
Import
import { niceScale, ChartFrame, ChartYAxis, ChartXAxis, ChartGridLines, ChartThreshold, ChartLegend, ChartTable } from "@ir/ui";Watch out
- Series colour follows the ENTITY, never its position in the filtered list. Pass a stable
idper series and the colour is derived from it, so hiding one series in the legend does not repaint the others. - There is no second y-axis, and there never will be. Two measures of different scale are two charts, or one chart indexed to a common base.
Props
| Prop | Type | Required | What it does |
|---|---|---|---|
title | React.ReactNode | Names the chart. With one series this is what identifies it, so there is no legend. | |
subtitle | React.ReactNode | Sits under the title — the window, the unit, the caveat. | |
action | React.ReactNode | Top-end controls: a range picker, a menu. |
Do and don't
Give each series a stable id and pass the whole list; the chart keeps each series on the slot it was built with.
Don't — Assign colours by position in the filtered list, so hiding one trunk repaints every trunk below it.
People read a colour as a name. If filtering out Sydney turns Melbourne from purple to blue, every reading taken before the filter is now wrong, and nothing on screen says so.
Pass null. The line breaks, and the table says "No data".
Don't — Fill a missing reading with 0, so a trunk that stopped reporting draws a cliff to the floor.
An endpoint going quiet and an endpoint scoring zero are different incidents with different responses. A line to the floor reports the second when the first happened.
Fill one series; draw several as lines.
Don't — Fill under several series at once and hope the overlaps read.
Overlapping translucent fills are the chart that looks informative and answers nothing — no overlap can be read as a value, and the series drawn last looks the largest. The component refuses area past one series rather than drawing it badly.
Two charts, or one chart with both measures indexed to a common base.
Don't — Put latency and call count on one chart with a scale down each side.
A dual axis lets whoever drew it decide where the lines cross, because the two scales are chosen independently. It is the single most common way a chart misleads, and there is no API for it here.
Fold the tail into one "Other" series, or facet into small multiples.
Don't — Generate a seventh colour when there are more series than slots.
The palette has six slots, and it has six because three of the declared eight could not be told apart from the others — corporate blue sits 7° from brand blue, IR lime is outside the usable lightness band, and teal cannot clear blue in both modes. A generated hue lands wherever there is room, which is usually next to a colour already in use. Both alternatives are decisions about the data, so the chart warns rather than deciding silently.
Render the data table visibly where exact values matter, and keep the chart for the shape.
Don't — Rely on the hover crosshair as the only way to read a number.
The crosshair is pointer-only. Someone navigating by keyboard, or reading the page without a pointer, gets the visually-hidden table — which is the right answer for a screen reader and no answer at all for a sighted keyboard user.
Accessibility
- The plot is
aria-hiddenand the numbers are carried by a visually-hidden table, so a screen reader gets the data rather than a shape it cannot see. labelis required and becomes the table's caption — it is what the chart is of, in a sentence.- A gap reads as "No data" in the table rather than as an empty cell, which would be indistinguishable from a cell that failed to render.
- The legend is always present from two series up and never for one, where the title names the series. Swatches carry identity; the text stays in ink, because a light series colour is illegible as text.
- Legend toggles are real buttons with
aria-pressed, and the last visible series cannot be hidden. - ⚠️ The crosshair is pointer-only. There is no keyboard equivalent yet — see the Do and Don't.
- Amber (slot 5) and IR red (slot 2) separate by only ΔE ~7 for protanopia and deuteranopia — inside the floor band, which is legal only with a second channel. The legend, the tooltip's series names and the data table are that channel; a chart stripped of all three should direct-label its lines.
Where it is drawn
Figma — structure from code, measurements from code.