Skip to Content
BBRICKSv0.7.4
KitCharts

AreaTrend

The mock's Analytics trend: 1000 × 230, peak × 1.1, gridlines at 25 / 50 / 75 %, area fill + stroke 3.

import { AreaTrend } from '@ergasti/bricks';

Examples

Area trend

A filled line over a period with a few x labels. Every chart takes a label (its accessible name) and draws a calm "no data" state for an empty series.

Code
import { AreaTrend } from '@ergasti/bricks';
import { mock } from './sample-data';

function Trend() {
  return (
    <div style={{ maxWidth: 700, background: 'var(--card)', borderRadius: 22, padding: 16 }}>
      <AreaTrend data={mock.SERIES.sales} xLabels={['14 Oct', '28 Oct', '13 Nov']} label="Sales, last 30 days" />
    </div>
  );
}

Spark and mini bars

The small charts that sit inside a tile. A null in the series is a gap.

Code
import { MiniBars, Spark } from '@ergasti/bricks';
import { mock } from './sample-data';

function Small() {
  return (
    <div style={{ display: 'flex', flexWrap: 'wrap', gap: 24, alignItems: 'flex-end' }}>
      <Spark data={mock.SERIES.sales} tone="lime" label="Sales" />
      <Spark data={[...mock.SERIES.roi.slice(0, 10), null, ...mock.SERIES.roi.slice(11)]} tone="sky" label="ROI with a gap" />
      <MiniBars data={mock.SERIES.orders.slice(-12)} tone="rasp" label="Orders" />
      <Spark data={[]} label="Empty" />
    </div>
  );
}

Tones

tone picks the line and fill colour: lime, rasp, butter or sky.

Code
import { AreaTrend } from '@ergasti/bricks';
import { mock } from './sample-data';

function Tones() {
  return (
    <div style={{ display: 'grid', gap: 12, gridTemplateColumns: 'repeat(auto-fit, minmax(260px, 1fr))' }}>
      {(['rasp', 'sky'] as const).map((tone) => (
        <div key={tone} style={{ background: 'var(--card)', borderRadius: 22, padding: 16 }}>
          <AreaTrend data={mock.SERIES.orders} tone={tone} label={`Orders, ${tone}`} />
        </div>
      ))}
    </div>
  );
}

Props

Prop

Type

Design guidance

How the BRICKS design system uses AreaTrend. Written in docs/content/components/AreaTrend.md; the props above are read from the code, which wins where the two disagree.

A full-width area line chart for one metric over time; use it for the Analytics trend under the KPI tiles.

AreaTrend is the mock's Analytics trend, hand-drawn in SVG with no chart dependency: a 1000 × 230 viewBox stretched to the card width, three gridlines, a raspberry area fill and a 3px stroke. The y scale tops out at the peak × 1.1 so the line never touches the top. A null point is a gap that splits the line; it is never drawn as zero. Screen readers get a hidden table with every value instead of the shape.

Anatomy

  1. Plot (svg.kit-area, 230px tall, aria-hidden): gridlines at 25 / 50 / 75 % (--grid).
  2. Area per run of known points: a polygon filled rgba(199, 50, 92, 0.08).
  3. Line per run: a 3px --rasp polyline, non-scaling stroke.
  4. X labels (.kit-area-x, optional): the first, middle and last of xLabels, deduplicated, dir="ltr".
  5. Hidden series table (.kit-sr): caption = label, one row per point (xLabels[i] or the index, value or "—").

Variants

PropValueLookWhen
tone'lime' | 'rasp' | 'butter' | 'sky'Accepted for API parity with Spark, but AreaTrend always draws in --raspLeave unset
xLabelsomittedNo x axis lineInside a small card where dates are in the header
xLabelsstring[]Three labels: first, middle, lastThe Analytics trend ("14 Oct", "28 Oct", "13 Nov")

States

StateTriggerLook
Defaultdata has numbersArea and line across the full width
Gapnull entries in dataThe line and area break; each run is drawn separately
Emptydata=[]The charts.noData copy ("No data yet" / "لسه مفيش بيانات") as a muted 12px line, no SVG
Flat / all zeroevery value 0The peak falls back to 1, so the line sits on the baseline

Types

Series (data): ReadonlyArray<number | null>.

Usage

<Card>
  <AreaTrend data={SERIES.sales} label="Trend, last 30 days" xLabels={['14 Oct', '28 Oct', '13 Nov']} />
</Card>

The Analytics screen drives it from the selected KPI tile:

type Metric = 'sales' | 'orders' | 'commission' | 'roi';
const SERIES: Record<Metric, number[]> = { sales: [9800, 10400, 11200, 9900, 12800], orders: [41, 44, 52, 39, 58], commission: [1470, 1560, 1680, 1485, 1920], roi: [6.2, 6.4, 6.9, 6.1, 6.7] };
const tiles = [
  { key: 'sales' as const, tone: 'lime' as const, label: 'Sales', value: <Money value="312400.00" compact />, delta: 9.6 },
  { key: 'orders' as const, tone: 'rasp' as const, label: 'Orders', value: '1,284', delta: 7.9 },
  { key: 'commission' as const, tone: 'butter' as const, label: 'Commission', value: <Money value="46900.00" compact />, delta: 9.7 },
  { key: 'roi' as const, tone: 'sky' as const, label: 'ROI', value: <Money value="6.70" />, delta: 0.4 },
];

function AnalyticsTrend() {
  const [metric, setMetric] = useState<Metric>('sales');
  return (
    <>
      <div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16 }}>
        {tiles.map((tile) => (
          <Tile key={tile.key} size="metric" tone={tile.tone} label={tile.label} value={tile.value}
            delta={<Delta value={tile.delta} unit={tile.key === 'roi' ? 'abs' : '%'} context="vs previous 30 days" />}
            selected={metric === tile.key} onSelect={() => setMetric(tile.key)} />
        ))}
      </div>
      <Card>
        <AreaTrend data={SERIES[metric]} label="Trend, last 30 days" xLabels={['14 Oct', '28 Oct', '13 Nov']} />
      </Card>
    </>
  );
}

A day with no data (an outage) stays a gap:

<AreaTrend data={[12, 18, 21, null, null, 25, 30]} label="Orders, last 7 days" />

Where it appears

  • Brand › Analytics › trend card under the four KPI tiles (the mock's svg role="img" aria-label="Trend, last 30 days").
  • Screen: Analytics.

Guidelines

Do

  • Put it in a Card at full content width; the SVG stretches horizontally and keeps 230px height.
  • Pass xLabels with one entry per point, so the hidden table has real dates.
  • Use null for missing days, not 0.

Don't

  • Don't use it for small inline trends: use Spark in a Tile.
  • Don't rely on tone to recolour it; it is always raspberry.
  • Don't plot several series in one AreaTrend; it draws one.

RTL and Arabic

  • The plot does not mirror: time runs left to right in both languages, and the x label row is dir="ltr".
  • Pass Arabic date labels in xLabels if you want them; their order stays left to right.
  • The empty copy follows language.

Tokens

--grid (gridlines), --rasp (line), --ink-3 (x labels, empty text). The area fill is a fixed rgba(199, 50, 92, 0.08).

Accessibility

  • The SVG is aria-hidden; the data is exposed as a visually hidden <table> with a <caption> (label), row headers (xLabels or 1…n) and values ("—" for gaps).
  • Nothing is interactive; no focus stop.
  • The x labels are muted --ink-3 12px text and only decorate; the table carries the data.

Found in the source

  • ARIA attributes set: aria-hidden.

Read from the component's source and tests. See Accessibility for the patterns the library follows.

  • Spark: the same data as a small 120 × 46 line inside a Tile.
  • MiniBars: small bars, last one solid.
  • BarChart: the older bar chart with a y axis and hover tips.

See also: Gauge · HBars · Legend

Source

src/kit/patterns/Charts.tsx (line 89) on GitHub.

On this page