All components (204)
Trend
Surfaces · Trend
What it is and when to use it
The small line of a dashboard: how something has gone over the last seven days. What matters is not the drawing, it is that it is not a mute drawing: it carries a written summary and, below it, a real data table.
When to use it
- Next to a figure (
Stat) to show the shape: whether it goes up, goes down, or stays the same. pointsnames each value (days, months) in the table; without it, they are numbered.formatwrites the values your own way (euros, units); by default, the number in the active language.tableVisiblealso shows the table, for those who prefer to read the numbers.paddingshades below the line;markLast(on by default) marks the last value with a dot.
When not to
- Comparing categories or reading exact values:
BarChart. - The split of a total:
DonutChart. - Day-by-day activity over a whole year:
ActivityMap.
Keyboard: it is not focusable.
Accessibility: the drawing is role="img" and is named with the label and a written summary ("From 120 to 180: goes up by 50%. Minimum 96, maximum 180."). Below there is a table with caption and row and column headers, always available to the screen reader and hidden from view except with tableVisible. The visible label, if needed, is provided by whoever places it. With all values equal the line runs through the middle: a streak with no change is not a maximum.
Fine-tuning: no variables of its own: it is adjusted with the classes amset-trend and amset-trend--<tone>. The line, the fill and the dot use currentColor. The width is set by the container; the height, by height (40 px by default).
Context: without format, numbers are written in the language of LocaleProvider (or AmsetProvider).
What it looks like
| Point | Value |
|---|---|
| Mon 5 | 18 |
| Tue 6 | 22 |
| Wed 7 | 19 |
| Thu 8 | 27 |
| Fri 9 | 31 |
| Sat 10 | 42 |
| Sun 11 | 36 |
| Point | Value |
|---|---|
| Mon 5 | 1240 € |
| Tue 6 | 1180 € |
| Wed 7 | 1390 € |
| Thu 8 | 1310 € |
| Fri 9 | 1520 € |
| Sat 10 | 1740 € |
| Sun 11 | 1860 € |
| Point | Value |
|---|---|
| Mon 5 | 3 |
| Tue 6 | 2 |
| Wed 7 | 4 |
| Thu 8 | 3 |
| Fri 9 | 5 |
| Sat 10 | 7 |
| Sun 11 | 8 |
<Trend label="This week's orders" values={[18, 22, 19, 27, 31, 42, 36]} points={dias} markLast />
<Trend label="Sales this week" values={ventas} format={enEuros} padding tone="success" />
<Trend label="Returns this week" values={[3, 2, 4, 3, 5, 7, 8]} tone="error" />Props
Import it with import { Trend } from '@amset/ui'. Required props are marked.
| Prop | Type | What it does |
|---|---|---|
labelrequired | string | What is being measured. Required: a line without a name says nothing. |
valuesrequired | readonly number[] | — |
className | string | Merged with the library classes; it does not replace them. |
format | (value: number) => string | How values are written. By default, the number in the active language. |
height | number | — |
markLast | boolean | A thick dot on the last value. |
padding | boolean | Shades below the line. |
points | readonly string[] | What each point is called (dates, months). It appears in the data table. |
tableVisible | boolean | Also shows the table. For the screen reader it is always there. |
tone | "neutral" | "accent" | "secondary" | "tertiary" | "info" | "success" | "warning" | "error" | The color of the line. `neutral` is the gray of the secondary ink. Defaults to `accent`. |
It also accepts the attributes of the element it renders: className, style, data-*, aria-* and its events.
In the test bench
Every state and variant, to try one at a time, on its page at ui.amset.tech:
