Line Chart
Documentation Index
Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.
Our composable line chart with polished strokes, markers, and interactions.
Overview
Use a line chart to show trends, movement, and rate of change across an ordered dimension such as time. Use dots when individual observations matter and a brush when readers need to inspect a dense range.
Anatomy
LineChart owns the data, configuration, selection, and loading state. Add axes and a grid for context, one or more Line parts for the series, and optional Dot, Legend, Tooltip, and Brush parts for exploration.
Accessibility
Canvas charts need a nearby text summary or data table when the exact values are important. Use distinguishable stroke styles and clear series labels so meaning does not depend on color alone.
Installation
Usage
Our line chart is composable. <LineChart> is the container, and every part hangs off it as a compound member, <LineChart.Grid>, <LineChart.XAxis>, <LineChart.YAxis>, <LineChart.Legend>, <LineChart.Tooltip>, and one or more <LineChart.Line>, so a single import gives you the whole chart. Each <Line> carries its own strokeVariant, curveType, glowing, enableBufferLine, and isClickable, so one chart can mix stroke styles and make only some series interactive.
import { LineChart, type ChartConfig } from "honestui/charts";<LineChart data={data} config={chartConfig} curveType="monotone">
<LineChart.Grid />
<LineChart.XAxis dataKey="month" />
<LineChart.YAxis />
<LineChart.Legend isClickable />
<LineChart.Tooltip />
<LineChart.Line dataKey="desktop" strokeVariant="solid" isClickable>
<LineChart.Dot variant="border" />
<LineChart.ActiveDot variant="colored-border" />
</LineChart.Line>
<LineChart.Line dataKey="mobile" strokeVariant="dashed" glowing>
<LineChart.ActiveDot variant="default" />
</LineChart.Line>
</LineChart>ECharts renders to a <canvas>, so these children never mount as DOM. The root reads their props and compiles them into the ECharts option object. Same JSX, same presence semantics (omit a part and it doesn't render), same behavior, the children are declarative config, not live DOM nodes.
The config is the same contract as every Honest UI chart, each key maps a data key to a label and a per-theme colors array. See Chart Config for the full shape. Colors resolve from your CSS variables at runtime, so dark mode just works.
Canvas rendering has a few implementation details to keep in mind: multi-color gradients tint each dot with the color at its x-position; the glow is layered gradient strokes stacked under the line, following the series' color in place of an SVG blur filter; and the zoom brush is a themed mini chart driven by ECharts' native dataZoom rather than the custom HonestBrush.
Interactive Selection
Add isClickable to any <Line> (and to <Legend>) to make those series selectable, then handle events via the onSelectionChange callback on <LineChart>:
<LineChart
data={data}
config={chartConfig}
onSelectionChange={(selectedDataKey) => {
if (selectedDataKey) {
console.log("Selected:", selectedDataKey);
} else {
console.log("Deselected");
}
}}
>
<LineChart.XAxis dataKey="month" />
<LineChart.Legend isClickable />
<LineChart.Tooltip />
<LineChart.Line dataKey="desktop" strokeVariant="solid" isClickable />
<LineChart.Line dataKey="mobile" strokeVariant="solid" isClickable />
</LineChart>Loading State
Pass isLoading to show an animated skeleton, loadingPoints to set how many points it draws, and curveType to match the real chart's curve.
Buffer Line
With enableBufferLine, each line's last segment renders dashed while the rest stays solid, useful for marking projected, estimated, or incomplete data at the end of a series, as in financial charts and forecasting dashboards.
Hover Reveal
With enableHoverReveal, hovering colors each line only up to the pointer's position and mutes everything past it to a neutral gray, with the active dot riding the cursor, a scrubbing effect for reading a series left-to-right. When not hovering, the chart looks completely normal.
Examples
Examples with different settings. Change strokeVariant on a <Line> or curveType on the chart to restyle it.
Gradient Colors
Curve Types
Stroke Variants
Glowing Lines
API Reference
The chart is composed of several parts; the props below are grouped by part. On canvas each part is declarative config the root compiles.
The root container. It owns the data, shared selection state, loading skeleton, and optional native dataZoom brush. Everything visual is composed as its children and compiled into the ECharts option.
A single line series. Each <Line /> is self-contained, its own stroke, glow, and clickability, so a chart can hold any number of independently styled lines.
Point markers composed inside a <Line />. <Dot /> is the resting marker; <ActiveDot /> is the hovered marker. They render nothing on their own, the parent <Line /> reads their variant.
The category and value axes. Include <XAxis /> for x-axis labels and <YAxis /> for the y-axis; omit either to hide it. Both hide automatically while the chart loads.
The background grid lines. Include it to render the dashed horizontal split lines; omit it and they don't draw. Takes no props.
The hover tooltip. Include it to enable the tooltip; omit it and none shows. It reads the chart's selection state, dimming unselected series in its content.
The series legend, rendered as HTML above the canvas. Include it to show the legend; omit it and none shows. With isClickable, each entry toggles selection of its series.
An optional zoom brush below the chart, a themed mini chart driven by ECharts' native dataZoom. Include <LineChart.Brush /> to render it; dragging the range filters the main chart.