Synertech Web/ui v0.57.5 Site Storybook

Documentation / Charts

LineChart

Client@synertech/uiOpen in Storybook

Change over time, on one or several series. A series’ colour follows its position in series, never its rank: hiding a series from the legend does not repaint the others.

The value axis does not anchor at zero by default: a line is read by its slope, not by the length of its marks (y={{ includeZero: true }} when the absolute level matters). There is deliberately no second axis: two measures on two scales invent a correlation, draw two charts instead.

A "use client" component: hover with a crosshair and a tooltip listing every series, equivalent keyboard navigation, and tableView to expose the exact values to assistive technologies.

Examples

Basic usage

x.key names the field read on each row, series the measures drawn.

Open in a tab
import { LineChart } from "@synertech/ui";

const monthly = [
  { month: "Jan", revenue: 18400, cost: 12200 },
  { month: "Fév", revenue: 21100, cost: 13050 },
  { month: "Mar", revenue: 19800, cost: 13600 },
  { month: "Avr", revenue: 26500, cost: 15100 },
  { month: "Mai", revenue: 29200, cost: 15800 },
  { month: "Juin", revenue: 34800, cost: 17400 },
];

const euro = (value: number) => `${Math.round(value / 1000)} k€`;

export function Basic() {
  return (
    <LineChart
      title="Revenu et coût"
      description="Six derniers mois"
      data={monthly}
      x={{ key: "month", label: "Mois" }}
      series={[
        { key: "revenue", label: "Revenu" },
        { key: "cost", label: "Coût" },
      ]}
      y={{ format: euro }}
      height={260}
    />
  );
}

Line shape and zero anchoring

curve picks the interpolation; includeZero puts zero back in the domain when the level, not the slope, is what matters.

Open in a tab
import { LineChart } from "@synertech/ui";

const monthly = [
  { month: "Jan", revenue: 18400, cost: 12200 },
  { month: "Fév", revenue: 21100, cost: 13050 },
  { month: "Mar", revenue: 19800, cost: 13600 },
  { month: "Avr", revenue: 26500, cost: 15100 },
  { month: "Mai", revenue: 29200, cost: 15800 },
  { month: "Juin", revenue: 34800, cost: 17400 },
];

const euro = (value: number) => `${Math.round(value / 1000)} k€`;

export function CurveAndZero() {
  return (
    <LineChart
      title="Revenu mensuel"
      data={monthly}
      x={{ key: "month" }}
      series={[{ key: "revenue", label: "Revenu" }]}
      curve="step"
      y={{ includeZero: true, format: euro }}
      markers="always"
      height={220}
    />
  );
}

Dashed forecast

A projection is the same measure continued: forecastFrom splits each series into two segments instead of creating a new one.

Open in a tab
import { LineChart } from "@synertech/ui";

const monthly = [
  { month: "Jan", revenue: 18400, cost: 12200 },
  { month: "Fév", revenue: 21100, cost: 13050 },
  { month: "Mar", revenue: 19800, cost: 13600 },
  { month: "Avr", revenue: 26500, cost: 15100 },
  { month: "Mai", revenue: 29200, cost: 15800 },
  { month: "Juin", revenue: 34800, cost: 17400 },
];

const withForecast = [
  ...monthly,
  { month: "Juil", revenue: 37200, cost: 18100 },
  { month: "Août", revenue: 39900, cost: 18800 },
  { month: "Sep", revenue: 43100, cost: 19600 },
];

export function Forecast() {
  return (
    <LineChart
      title="Revenu et coût"
      description="Mesures jusqu’en juin, projection ensuite"
      data={withForecast}
      x={{ key: "month" }}
      series={[
        { key: "revenue", label: "Revenu" },
        { key: "cost", label: "Coût" },
      ]}
      forecastFrom="Juin"
      forecastLabel="prévision"
      legendToggle
      height={260}
    />
  );
}

Thresholds and annotations

referenceLines say what counts as too much, annotations explain why the line moved: a band, a dated event or a commented point.

Open in a tab
import { LineChart } from "@synertech/ui";

const monthly = [
  { month: "Jan", revenue: 18400, cost: 12200 },
  { month: "Fév", revenue: 21100, cost: 13050 },
  { month: "Mar", revenue: 19800, cost: 13600 },
  { month: "Avr", revenue: 26500, cost: 15100 },
  { month: "Mai", revenue: 29200, cost: 15800 },
  { month: "Juin", revenue: 34800, cost: 17400 },
];

const withForecast = [
  ...monthly,
  { month: "Juil", revenue: 37200, cost: 18100 },
  { month: "Août", revenue: 39900, cost: 18800 },
  { month: "Sep", revenue: 43100, cost: 19600 },
];

const euro = (value: number) => `${Math.round(value / 1000)} k€`;

export function Annotated() {
  return (
    <LineChart
      title="Revenu mensuel"
      description="Les annotations disent ce que la pente ne dit pas"
      data={withForecast}
      x={{ key: "month" }}
      series={[{ key: "revenue", label: "Revenu" }]}
      y={{ format: euro }}
      referenceLines={[{ value: 30000, label: "Objectif" }]}
      annotations={[
        { type: "band", from: "Fév", to: "Mar", label: "Campagne" },
        { type: "line", x: "Mai", label: "Refonte du tunnel" },
        { type: "point", x: "Août", y: 39900, label: "Record" },
      ]}
      height={280}
    />
  );
}

Monitoring dashboard

Time axis, SLA threshold, table view on demand and a click on a point: over 60 points, markers="auto" drops the markers on its own.

Open in a tab
import { LineChart } from "@synertech/ui";

const daily = Array.from({ length: 60 }, (_, index) => ({
  day: new Date(2026, 3, 1 + index),
  latency: 140 + Math.round(Math.sin(index / 6) * 25 + (index % 7) * 4),
}));

export function LatencyDashboard() {
  return (
    <LineChart
      title="Temps de réponse médian"
      description="60 derniers jours"
      data={daily}
      x={{ key: "day", scale: "time", label: "Jour" }}
      series={[{ key: "latency", label: "Latence" }]}
      y={{ format: (value) => `${value} ms` }}
      referenceLines={[{ value: 200, label: "SLA" }]}
      grid="y"
      tableView="toggle"
      locale="fr-FR"
      onPointClick={(point) => console.log(point.x, point.formattedValue)}
      height={240}
    />
  );
}

API reference

Components

LineChart

ComponentClient

Change over time.

Unlike a bar chart, the value axis does not anchor at zero by default: a line is read for its slope, not for the length of its marks. Pass y={{ includeZero: true }} when the absolute level is the point.

There is deliberately no second value axis. Two measures on two scales invent a correlation the data does not carry; plot them as two charts, or index both to a common base.

overlay is the way past everything this chart refuses to draw: it hands the resolved geometry over and lets the application draw inside the plot with the chart's own scales, instead of forking the component.

import { LineChart } from "@synertech/ui";

Props — LineChartProps

PropTypeDefaultDescription
data• ChartDatum[] —
series• ChartSeries[] —
x• ChartXAxisConfig —
actions ReactNode —

Slot on the right of the caption: an export button, a range picker.

A filter that frames several panels belongs in a ChartFilterBar above all of them; this is for what belongs to this panel alone.

annotations ChartAnnotation[] —

What happened, drawn where it happened: a release, a campaign, an outage.

The counterpart of referenceLines, which marks a threshold on the value axis. A spike nobody explained is a question rather than an answer, and the explanation almost always sits on the time axis.

The captions are appended to the chart's accessible name, since an SVG exposes nothing drawn inside it.

brush boolean false

Lets a pointer drag a window across the category axis.

Shift + arrows does the same from the keyboard, and Escape drops it. The window is published to the surrounding ChartSyncProvider, which is how one panel's selection becomes the whole dashboard's.

brushLabel string —

Accessible name of the selected window.

className string —
connectNulls boolean false

Draws through the gaps instead of breaking the line.

curve ChartCurve "monotone"
description ReactNode —
emphasis string —

Paints one series in its colour and greys out every other one.

emptyState ReactNode —

Replaces the "no data" state: usually an EmptyState saying why, and what to do.

error boolean false

The data could not be loaded.

Never the same thing as having none: a panel that says "no data" after a failed request states something false, and offers no way out.

errorState ReactNode —

Replaces the whole built-in error state, message and button included.

forecastFrom ChartXValue —

Dashes every series from this x value on.

One series, two path segments: a projection is the same measurement continued, and drawing it as a separate series would claim otherwise. A date that falls between two rows starts the forecast on the first row after it; one that no row reaches draws nothing dashed, and says so in the console.

forecastLabel string —

Caption above the line that separates the measured past from the forecast.

grid ChartGridLines "y"
height number 240

Height of the plot area in pixels. Width always follows the container.

legend boolean | ChartLegendPosition —
legendToggle boolean true

Lets the legend show and hide series.

loading boolean false

Dims the plot while fresh data loads; a first load shows a spinner.

locale string —

BCP 47 tag the numbers and the dates are written in. Defaults to the locale of UILabelsProvider, then to the language of the runtime.

margin Partial<ChartMargin> —
markers "none" | "auto" | "always" "auto"

auto draws the points when they have room to breathe.

maxPoints number —

Thins the drawn path to roughly this many points per series.

A series of fifty thousand rows builds a d attribute of fifty thousand coordinates, most of which land on a pixel column another one already covers. This runs the points through LTTB, which keeps the peaks a stride sample walks straight past.

Only the path is thinned. The geometry, the crosshair, the tooltip and the data table keep reading every row, so no value stops being reachable — the chart draws the same shape from fewer points, it does not hold less data. Left unset, every point is drawn and a series past CHART_POINT_BUDGET warns once in development.

onBrush (range: ChartBrushRange | null) => void —

Called when a window is set, and with null when one is dropped.

onPointClick (event: ChartPointEvent) => void —

Called with the mark that was clicked.

Enter and Space on the focused chart do the same for the mark the keyboard is on.

onRetry () => void —

Draws the retry button in the error state, and is called when pressed.

overlay ChartOverlay —

Draws inside the plot, with the chart's own resolved geometry.

plotLabel string —

Describes the plot for assistive technology. The table view carries the values.

referenceLines ChartReferenceLine[] —
size ChartSize "md"
sync boolean true

false keeps the chart out of the surrounding ChartSyncProvider.

For the panel of a dashboard that plots something else entirely, where a shared crosshair would mark a position its axis does not carry.

tableView boolean | "toggle" false

Renders the accessible data table: always (true) or behind a button.

title ReactNode —
tooltip boolean | ((payload: ChartTooltipPayload) => ReactNode) true

false disables the hover layer; a function replaces its content.

width number —

Fixes the width instead of measuring the container.

y ChartYAxisConfig —

+ 276 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).