Bridge UI

ChartLine

Line and area charts: trends, stacked areas, value colors, steps, reference lines, time axes, and sparklines.

Introduction

ChartLine draws lines and areas over a shared set of categories. Compose it with ChartLineSeries, ChartAxis, ChartLegend, and ChartTooltip. Every series has one value per category. Shared parts, colors, and accessibility are in Chart.

When to use: Trends over an ordered set of categories — days, weeks, months — and compact sparklines in cards.

Compared to similar components:

  • ChartBar — Comparing amounts between categories, rankings, or stacked totals.
  • ChartScatter — Two numeric values per point instead of one value per category.

Use the framework selector in the site header to switch between React and Vue.

Import

import { ChartLine } from "@bridge-ui/vue/Components/ChartLine";
import { ChartLineSeries } from "@bridge-ui/vue/Components/ChartLineSeries";
import { ChartLine } from "@bridge-ui/react/Components/ChartLine";
import { ChartLineSeries } from "@bridge-ui/react/Components/ChartLineSeries";

Add ChartAxis, ChartLegend, and ChartTooltip from Chart.

Basic usage

Pass the category labels as categories and add a ChartLineSeries per data set. A null value leaves a gap and is skipped in the tooltip.

Area and stacked area

area fills under the line; curve="smooth" rounds it. Set them on the root for every series, or per series. Series with the same stack key stack on top of each other.

areaOpacity sets the fill opacity (0.15 by default). Stacked bands read better with a stronger fill. Set it on the root for every series, or per series.

Color by value

colorRanges recolors the line (and its area) piece by piece. A value in [min, max) takes the range color; values outside every range keep the series color. Range labels show in the tooltip, the data table, and the keyboard announcements.

With colorBy="category", min and max are category indices (zero-based, both included): the line changes color over that stretch of the axis, for example to highlight a campaign. On a time axis the indices still point at the categories.

Step, dashed, points, and reference lines

step draws a step line (start, middle, or end). dashed dashes the stroke and showPoints always draws the point symbols.

reference draws a dashed line for a statistic of the series (average, min, max) or a fixed value, each with an optional label.

Time axis

Pass dates as categories to get a time axis: points are spaced by elapsed time, and tick labels (days, months, years) follow the span and the Bridge locale. formatDate formats the dates in the tooltip, data table, and summary. On a time axis, ChartAxis formatTick receives the timestamp (ms).

Sparkline

sparkline drops axes, grid, and padding, and defaults the height to 48 (also over a registry height). The summary and data table stay.

Value labels

labels draws the value of each point on the plot. formatLabel formats value labels and reference line labels.

<ChartLine labels :categories="months" :format-label="(value) => `${value}k`">
  <ChartLineSeries name="Revenue" :data="revenue" />
</ChartLine>
<ChartLine labels categories={months} formatLabel={(value) => `${value}k`}>
  <ChartLineSeries name="Revenue" data={revenue} />
</ChartLine>

Keyboard and accessibility

Arrow keys move between categories. The root generates a summary with the series names and the category range. See Chart for the shared keyboard and accessibility behavior.

Chart, ChartBar, ChartScatter

API

ChartLine

Shared root props (height, palette, loading, summary, …) are listed in Chart.

Prop Type Default Description
area boolean false Fill under every series.
areaOpacity number 0.15 Area fill opacity (0–1) for every series. Vue: area-opacity.
categories string[] | Date[] — Required. Category labels, or dates for a time axis.
curve "linear" | "smooth" "linear" Interpolation for every series.
formatDate (date: Date) => string — Date labels in the tooltip, table, and summary. Vue: format-date.
formatLabel (value: number) => string — Value labels and reference line labels. Vue: format-label.
labels boolean false Value labels on every series.
showPoints boolean false Always draw point symbols. Vue: show-points.
sparkline boolean false No axes, grid, or padding; 48px default height.
stack string — Stack every series under this key.
step false | "start" | "middle" | "end" false Step line for every series.

ChartLineSeries

Unset options fall back to the ChartLine props. Inside a ChartBar, the series draws a line over the bars.

Prop Type Default Description
area boolean root Fill under the line.
areaOpacity number root Area fill opacity (0–1). Vue: area-opacity.
color ChartColorValue palette Token key or any CSS color.
colorBy "value" | "category" "value" category matches colorRanges against category indices (both ends included). Vue: color-by.
colorRanges ChartColorRangeOption[] — { min?, max?, color, label? }: the line takes color where the value is in [min, max). Vue: color-ranges.
curve "linear" | "smooth" root Interpolation.
dashed boolean false Dashed stroke.
data (number | null)[] — Required. One value per category. null leaves a gap.
labels boolean root Value labels.
name string — Required. Legend, tooltip, and table label.
reference ChartReference | ChartReference[] — { type: "average" | "min" | "max" } or { value }, each with an optional label.
showPoints boolean root Point symbols. Vue: show-points.
stack string root Stack key.
step false | "start" | "middle" | "end" root Step line.