Trend#

A value with its direction of travel against the previous reading: , or ·.

Import#

TSX
import { Trend } from '@sigx/terminal';

Usage#

TSX
<Trend current={p99} previous={prevP99} value={`${p99}ms`} />
<Trend current={rps} previous={prevRps} value={`${rps}/s`} polarity="higher-is-better" />

polarity is not decoration#

Whether "up" is good news depends entirely on the metric. Rising latency is a problem; rising throughput is not. A component that hardcoded ▲ = warning would be lying about half the numbers on a dashboard — so the metric has to say which it is:

polarityUpDownFor
higher-is-worse (default)warnsuccesslatency, error rate, queue depth, memory
higher-is-bettersuccesswarnthroughput, hit rate, healthy replicas
neutraldirection only, no judgement

A null on either side is a gap, not a direction. Comparing across a counter reset would report a crash that never happened.

Props#

PropTypeNotes
currentnumber | nullrequirednull is a gap
previousnumber | nullthe reading to compare against
valuestringthe text shown; defaults to the number
polarity'higher-is-worse' | 'higher-is-better' | 'neutral'default 'higher-is-worse'
colorstringoverride the polarity tone

See also#

  • Sparkline — the whole series behind the direction.