Skip to content
opsinjs
Edit this page

Patterns

Trend review

Reading change over time without over-interpreting noise, with minimum windows, honest axes and direction kept apart from valence

The reader's question is "is this getting better or worse", not "what is my number". By default, charts mislead here. Three points make a line, an axis fitted to the data turns a small drift into a cliff, and a nightly average changes direction twice a week.

When to use it

Use it when the reader compares a value with their own history, the measure varies day to day, and someone might change a behaviour or a dose because of the line. Use something else for:

How it works

  1. Count the readings. Below the metric's minimum, show the points with no line and no direction word, and say how many more are needed. Your product owns that minimum.
  2. Fix an honest axis. Zero where zero means something, otherwise the reference band or a fixed span. Keep it stable, and never fit it to the data.
  3. Compare the change with the noise. A change smaller than the measure's own variation is "about the same", with no direction named.
  4. Name direction, never valence. Up, down or about the same. Down is not worse. A status your rule assigned appears in words beside the chart and never recolours the line.
  5. Write the caption. Direction, size, unit and window, in words. The caption is the deliverable and the chart illustrates it.
  6. Ship the table twin, with the same numbers, on the page, in every state.

Gaps are drawn as gaps, never interpolated. A stale series promotes its last-updated stamp and demotes the direction. Series in different units are split, never rescaled onto one axis. No causal language: "your sleep improved because you walked more" is a claim self-tracked data cannot support.

NOT IMPLEMENTED. This component does not exist in any released version of opsinjs. There is no package to install, no module to import and no props interface to generate code against. Everything on this page is a specification of intended behaviour and may change without notice. Do not write code against it.

This component is not built yet

There is nothing to render because there is nothing to install. What you can read on this page is the specification the implementation will have to satisfy.

PlannedRoadmapWhat “planned” means

Components

Trend with an honest caption

import { TrendSparkline } from "@/components/ui/trend-sparkline"

<TrendSparkline
  label="Example measurement"
  unit="steps"
  precision={0}
  locale="en-GB"
  window="the last 6 entries"
  series={series}
  minimumPoints={readingsATrendNeeds}
/>

minimumPoints is required and has no default. Below it nothing is drawn, and the caption says why. changeThreshold is the smallest difference your metric counts as a change, and without it the caption names no direction. A gap is an entry with value: null, never an omitted one.

To write your own sentence, pass caption. The count of readings and of missing entries is still appended. Keep to this shape:

<metric> <direction> <magnitude> <unit> over <window>, compared with <comparison window>. <what a change of this size does not mean>

"Your resting heart rate was about 4 bpm lower over the last 7 days than the 7 days before. Day-to-day variation of this size is common and does not on its own mean anything has changed." Lead with absolute change, because a percentage of a small number makes a trivial change sound large. Never congratulate or commiserate.

Not written yet.

Marking an event on the line itself, such as a medication change or an illness, has no component and no guidance yet. TimelineEntry covers a dated history list, not the chart.

Example

Viewport width
Theme
Accent theme
Accent

NOT IMPLEMENTED. The opsinjs component `trends-screen` does not exist in any released version of opsinjs. There is no package to install, no module to import and no props interface to generate code against. Everything on this page is a specification of intended behaviour and may change without notice. Do not write code against it.

trends-screen is not built yet

This frame will embed /view/base/base-lyra/screen/trends-screen?mode=light, which renders under the product theme rather than the documentation chrome. There is nothing at that address yet.

PlannedRoadmapWhat “planned” means

Phone · 390px · /view/base/base-lyra/screen/trends-screen?mode=light

The trends screen is still a specification, so its frame shows the not-built notice. Its caption sits inside the card with the chart, so the two cannot be screenshotted apart.

Accessibility

  • The caption is the chart's accessible description, not "line chart showing resting heart rate".
  • Changing the metric or window announces the new summary politely and does not move focus.
  • A focused point announces its value, unit and date, and every value is in the table without a gesture.
  • No draw-on animation carries meaning, and at 200% text the sentence is never truncated.