Skip to content
GitHub (opens in a new tab)

Line

Change and progress over ordered samples as a line or area chart.

stableOrganismcontracts/linechart.json

Preview

Chart

Line

Change over time. Follow a trajectory, not unrelated magnitudes. Not a Chart cousin.

Master

One series over time, as an area with the grid. Variants shows line, multiple series and more.

Weekly active users

Daily average, last 7 days

Usage

Use LineChart for change over time. Hover a moment to read the sample. Area fills the path; line keeps the stroke only.

Do's

  • Following a trajectory across time or sequence
  • Multi-series trends with shared labels
  • Parts of a total over time, like usage by plan by month — variant area with stack stacked
  • Each part's share of the total over time — variant area with stack percent
  • This period against the last — a second series with dashed true
  • Showing a target or average — referenceLine, with highlight to mark points past it
  • A headline value with how it moved each day — highlightLast with a changeStrip
  • This period against the last on demand — a Compare Button in actions that adds a dashed series

Don'ts

  • Comparing unrelated magnitudes at one moment — use BarChart
  • Part-to-whole share at one moment — use PieChart
<LineChart
  title="Weekly active users"
  description="Daily average, last 7 days"
  data={[
    { label: 'Mon', value: 1240 },
    { label: 'Tue', value: 1380 },
  ]}
/>

When to use

  • Following a trajectory across time or sequence
  • Multi-series trends with shared labels
  • Parts of a total over time, like usage by plan by month — variant area with stack stacked
  • Each part's share of the total over time — variant area with stack percent
  • This period against the last — a second series with dashed true
  • Showing a target or average — referenceLine, with highlight to mark points past it
  • A headline value with how it moved each day — highlightLast with a changeStrip
  • This period against the last on demand — a Compare Button in actions that adds a dashed series

When not to use

  • Comparing unrelated magnitudes at one moment — use BarChart
  • Part-to-whole share at one moment — use PieChart

What an agent reads

import { LineChart } from "agentic-ds-kit";
must
  • Title on figure when provided
  • The plot svg is role=group named by the title when it holds focusable points (role=img only when empty)
  • Hover reads the sample
  • Legend highlight emphasises one series
  • Table view keeps values readable
  • animate is decorative only: no motion under prefers-reduced-motion, and hover, focus, legend and table work during the entrance
  • referenceLine: the table caption names the label and value; a highlighted point's accessible name adds "(above <label>)" or "(below <label>)"
  • dashed series are told apart by their legend label, not by the dash alone
  • changeStrip values are in the tooltip, the table and each point's accessible name; up and down are told by the sign, not by colour
  • The highlightLast chip is decorative (aria-hidden); the value stays in the table and the point's name
  • error replaces the plot with a role=alert row; Retry is a real Button
  • tooltipNote is read with the tooltip (role=status)
defaults
  • highlightLast false
  • variant area
  • stack none
  • curve smooth
  • showGrid true
  • showTable true
  • includeZero false
  • height 240
  • emptyLabel No data for this range
  • isLoading false
  • animate false
stops if
  • Do not invent chart container cousins
  • Do not draw bars and a line on one chart from two charts — use ComboChart
  • Do not plot two numeric measures per item (x against y) — use ScatterChart
  • Do not stack series that can go negative; a stacked band starts where the one below ends, so a negative value has nowhere to go
  • Do not stack values that do not add up to a real total, like rates, averages or overlapping counts; use stack none
  • Do not set stack with variant line; stacking needs filled bands
  • Do not use raw hex
  • Do not draw a reference line or threshold with a second flat series — use referenceLine
  • Do not overlay a second chart to show the previous period — use a dashed series
  • Do not use status colours for highlighted points; the accent dot means past the line, the label says which way
  • Do not wrap a chart in a Card only to get a header button — pass actions
  • Do not draw a change strip as a second chart under the first — use changeStrip so labels, crosshair and tooltip stay shared
  • Do not colour strip bars green and red; a loss is a negative bar and its sign says so
  • Do not keep the comparison series on by default when it is only context — put a Compare Button in actions
  • Do not round line ends; the kit draws square ends and joins

From contracts/linechart.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
dataarrayNo——
labelsarrayNo——
seriesarrayNo—{ label, data: number[], color?, dashed? }[]. dashed draws the series as a dashed line with no area fill and a dashed legend swatch, for a comparison such as the previous period; it still counts toward the value axis.
referenceLineobjectNo—One dashed horizontal guide (text.muted) at value, with its label at the line's right end. The value axis widens to include it. highlight marks points of solid series above (or below) it with an accent dot (fill.brand); not with stack (the edges are running totals). The table gets a caption with the label and value, and each point's name says when it is past the line. Ignored with stack percent.
highlightLastbooleanNofalseA dot and a value chip on the latest point of the first solid series, like today's MRR. Ignored with stack.
changeStripobjectNo—A short bar strip under the plot on the same labels, like net change per day. Bars go up from zero for gains and down for losses, square, in the first solid series' colour, on their own scale with two axis labels. It shares the crosshair and tooltip, adds a legend item and a table column, and joins each point's accessible name. format defaults to a signed compact number with a real minus sign (+1,200, −1,600).
titlestringNo—Chart heading. A title, legend, actions or the Table toggle draw the chart's own frame; directly in a Card body the frame is dropped and the Card is the frame.
descriptionstringNo——
variantline | areaNoarea—
stacknone | stacked | percentNononeOnly with variant area. stacked piles the series as bands from the bottom up, so the top edge is the total; percent scales each column to 100% so the bands show each series' share. Missing or negative values count as 0. Ignored with variant line, with a warning in development
curvesmooth | linearNosmoothsmooth rounds the line through every point (monotone: no overshoot above peaks or below dips); linear draws straight segments
showGridbooleanNotrue—
showTablebooleanNotrue—
includeZerobooleanNofalse—
heightnumberNo240—
emptyLabelstringNoNo data for this range—
isLoadingbooleanNofalse—
errorstringNo—When set, the plot is replaced by the kit's "Couldn't load" row (role=alert) with this message. Say what failed and that data is safe, like "Stripe didn't answer in time."
onRetryfunctionNo—Shows an outline Retry Button on the error row.
tickIntervalnumberNo—draw every Nth axis label; with neither tickInterval nor formatLabel, labels thin automatically only when they would overlap
formatLabelfunctionNo—(label, index) => string for the painted axis label; return '' to hide one (turns off automatic thinning). Table and accessible names keep the raw label
tooltipNotefunctionNo—(index) => string | undefined. One sentence under the tooltip rows for that sample, like "The largest drop in 30 days." Read with the tooltip; keep it short and plain.
animatebooleanNofalseLines draw in left to right and area fills fade in after when the chart first appears. Runs when the chart mounts; changing data on a mounted chart does not replay it. To replay (e.g. one chart per Tabs panel, or a range switcher), give the chart a key that changes with the data. Off under prefers-reduced-motion
actionsslotNo—Kit Buttons in the chart header, before the Table toggle, like an icon-only Ask. ghost sm reads quietest. Setting it draws the frame even with no title.
  • Component
    →

    Bar

    Compare magnitudes across categories with vertical or horizontal bars.

  • Component
    →

    Pie

    Part-to-whole share for a handful of segments, as a donut or solid pie.

  • Component
    →

    Chat

    Assistant panel with a header, a thread, and a composer.

  • Block
    →

    Anomaly detail

    One metric anomaly an agent flagged, so a person understands it before anything is fixed.