Skip to content

Components

LineChart

Weekly visits
466
Use the arrow keys to explore values, or Home and End to jump.

Component reference

Properties

Use LineChart

A line or area chart for comparing trends on a shared scale.

Example import style
line-chart.tsxTSX
"use client";

import { FloodRoot, LineChart } from "@flood-md/react";
import "@flood-md/react/styles.css";

export function Example() {
  return (
    <FloodRoot>
      <LineChart label="Daily visits" categories={["Mon", "Tue", "Wed"]}
        series={[{id:"this-week", label:"This week", values:[38, 55, 48]}]}
        domain={[0, 60]} variant="area" />
    </FloodRoot>
  );
}

Design notes

  • The chart shows dates and a quiet dot grid by default. Enable showYAxis when numeric levels need to be visible at a glance.
  • Series names appear in the inspection readout. Set showLegend when the key needs to be visible before interaction.
  • Supply equally spaced categories in reading order and up to four named series with the same number of values. Null and nonfinite values leave gaps. Zero is an observation.
  • Use a shared domain containing all observations when comparing separate charts. Area shading belongs to the first series. Line styles distinguish the series independently of color. Set curve to linear for straight segments.
  • Explore values by hovering, tapping, or using arrow keys, Home and End. The default number format is English; supply formatValue and translated empty, missing and navigation labels for other locales.

API reference

PropValuesDefault
labelstringRequired
categoriesreadonly string[]Required
seriesreadonly LineChartSeries[]Required
domainreadonly [number, number]—
variant"line" | "area""area"
curve"linear" | "smooth""smooth"
showYAxisbooleanfalse
showLegendboolean—
formatValue(value: number) => string—
emptyLabelstring"No data"
missingLabelstring"No value"
navigationLabelstring"Use the arrow keys to explore values, or Home and End to jump."
Native HTML propsOmit<HTMLAttributes<HTMLDivElement>, "children" | "role" | "aria-label">Forwarded
View TypeScript source