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 exact values or trends are important. Use distinguishable stroke styles and clear series labels so meaning does not depend on color alone. Tooltip, brush, and direct line selection are pointer-operated; provide equivalent controls when those interactions are required.
Installation
Usage
<LineChart> owns the data, theme configuration, and shared state. Add axes, a grid, legend, tooltip, brush, and one or more <LineChart.Line> parts as needed. Each Line sets its own stroke, curve, markers, buffer treatment, and selection behavior.
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="buys" strokeVariant="solid" isClickable>
<LineChart.Dot variant="border" />
<LineChart.ActiveDot variant="colored-border" />
</LineChart.Line>
<LineChart.Line dataKey="sells" strokeVariant="dashed" glowing>
<LineChart.ActiveDot variant="default" />
</LineChart.Line>
</LineChart>The root compiles its children into an ECharts option and renders the plot on a canvas. The config prop maps each series data key to its label and theme colors. See Chart Config for the complete shape.
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="buys" strokeVariant="solid" isClickable />
<LineChart.Line dataKey="sells" 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.