Instruments Delta
// Delta

Delta

The change in a value — arrow for direction, figure for magnitude, colour for good vs bad — computed each tick against the previous reading.

<talos-delta> reports the change in a value, not the level: the sign of value − previous picks the arrow (▲ up / ▼ down / ▬ flat), |Δ| is the figure, and colour is the verdict — up is good, down is bad by default, and good="down" flips that for metrics where falling is healthy. The verdict rides the glyph itself, so a glance reads “which way, and is that good” before you read the number. Δ is computed against the last reading, so a fresh element with one value has no prior and shows flat ▬ 0 until value changes again.

Default — first reading

LIVE
<talos-delta value="42"></talos-delta>

With no prior reading there is no change to report, so the element rests at ▬ 0 in the tertiary (flat) colour. Set value again — via the attribute or el.update(n) — and the next render shows the signed Δ vs this reading.

Direction — up, down, flat

The arrow and colour come from the sign of value − previous. Up reads --talos-success, down reads --talos-danger (with the default good="up"); a step within eps reads flat in the tertiary colour.

<talos-delta value="42"></talos-delta>
<!-- later, against a prior of 40 → ▲ in success -->
el.update(45);
<!-- against a prior of 45 → ▼ in danger -->
el.update(41);

Direction needs a prior, so it only appears once value changes against an earlier reading — feed it each tick to turn a static number into a monitorable one. Pair it beside a level readout: the number is where, the delta is which way and how much.

good=“down” — falling is healthy

PREVIEW
<talos-delta value="120" good="down"></talos-delta>

Flips the colour mapping: a downward step reads --talos-success and an upward step reads --talos-danger. For latency, error rate, cost, queue depth — any metric where down is the win — a falling Δ reads green without inverting the data.

precision — decimal places

PREVIEW
<talos-delta value="3.14159" precision="2"></talos-delta>

precision sets the decimal places on the magnitude figure (default 0, floored at 0). The arrow and colour are unaffected — only the rendered |Δ| is formatted.

eps — dead-zone

PREVIEW
<talos-delta value="50" eps="0.5"></talos-delta>

eps is a dead-zone: any change with |Δ| ≤ eps reads flat (▬, tertiary colour) instead of tripping an arrow. Use it to keep jittery signals from flickering direction on noise (default 0 — every non-zero step shows).

Behaviour

value is reactive — re-set it (or call el.update(value)) and the delta recomputes against the prior reading. Exposes ::part(arrow) and ::part(mag) for styling the glyph and figure; --talos-delta-size sets the font size.

Attributes

Generated from custom-elements.json in the installed package. Shared attributes (state, format, static…) behave as the instrument contract describes.

AttributeTypeDefaultDescription
value number — current value; set it each tick and Δ is computed vs the last.
from number — previous value; when set, Δ = value − from (static use, SSR)
good string — "up" | "down" — which direction is the healthy one.
eps number 0 dead-zone; |Δ| below this reads as flat.
label string — names the metric in the accessible label.
format string — number | compact | percent | bytes | duration | currency; the readout's number format
precision string 0 decimal places for the magnitude.
currency string — ISO 4217 code when format=currency
locale string — BCP 47 locale for formatting; defaults to the page locale
state string — live | loading | stale | offline | unknown; sets data-state on the host
updated-at string — time of the last sample (ISO or epoch ms); drives the age caption
stale-after string — seconds after updated-at at which the element reads stale

Properties and methods

MemberTypeDescription
.value number | null The current reading; mirrors the `value` attribute (null = no data).
update() method Imperative equivalent of setting `value`.

CSS parts

::part(arrow), ::part(mag)