Charts

Copy-paste chart examples for every Bklit UI component.

Line Chart - Trio with Brush

Three Catmull–Rom series on a dot background with a top legend and brush zoom — matches the Studio trio preset.

import { curveCatmullRom } from "@visx/curve";import {  Background,  ChartBrush,  ChartBrushLayout,  ChartLegend,  ChartTooltip,  Line,  LineChart,  XAxis,} from "@bklitui/ui/charts";<ChartBrushLayout data={chartData} enabled height={72} brushStrip={...}>  {(brushLayout) => (    <LineChart data={chartData} xDomain={brushLayout.xDomain} tweenYDomainOnXDomainChange>      <Background pattern="dots" opacity={0.85} />      <Line dataKey="desktop" curve={curveCatmullRom} fadeEdges stroke="var(--chart-1)" strokeWidth={2} />      <Line dataKey="mobile" curve={curveCatmullRom} fadeEdges stroke="var(--chart-2)" strokeWidth={2} />      <Line dataKey="tablet" curve={curveCatmullRom} fadeEdges stroke="var(--chart-3)" strokeWidth={2} />      <XAxis />      <ChartTooltip />    </LineChart>  )}</ChartBrushLayout>const chartData = Array.from({ length: 30 }, (_, i) => ({  date: new Date(2025, 0, 1 + i),  desktop: Math.round(180 + Math.sin(i / 4.2) * 70 + ((i * 9) % 31)),  mobile: Math.round(120 + Math.cos(i / 3.8) * 55 + ((i * 5) % 23)),  tablet: Math.round(150 + Math.sin(i / 5.1 + 1) * 48 + ((i * 7) % 19)),}));

Open the same preset in Studio from the Background docs or paste the share URL from /charts/line-chart.

Line Chart - Projection

Target and auto forecasts with gradient dashed beziers and a terminal marker

import {  buildProjectionPath,  LineSeriesTerminalMarker,  ProjectionLine,} from "@bklitui/ui/charts";const targetProjectionPath = buildProjectionPath({  sourceData: chartData,  seriesKey: "value",  mode: "target",  pathDensity: "endpoints",  horizonPoints: 6,  endValue: 301,});const autoProjectionPath = buildProjectionPath({  sourceData: chartData,  seriesKey: "value",  mode: "auto",  autoMethod: "lastSegment",  pathDensity: "endpoints",  horizonPoints: 6,});<LineChart data={chartData}>  <Grid horizontal />  <Line dataKey="value" strokeWidth={2} />  <LineSeriesTerminalMarker dataKey="value" />  <ProjectionLine    data={targetProjectionPath}    strokeDasharray="1,4"    curveKind="bezier"    strokeStyle="gradient"    showEndMarker  />  <ProjectionLine    data={autoProjectionPath}    strokeDasharray="1,4"    curveKind="bezier"    strokeStyle="gradient"    showEndMarker  />  <XAxis />  <ChartTooltip /></LineChart>

See the [Projection Line utility](/docs/utility/projection-line). Projections and brush zoom are not supported together.

Line Chart - Linear

Straight lines between data points

import { curveLinear } from "@visx/curve";<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Grid horizontal />  <Line dataKey="desktop" curve={curveLinear} strokeWidth={2} />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - Markers

Custom markers to annotate key events

const markers = [  { date: new Date(2024, 2, 1), icon: "🚀", title: "v2.0 Launch" },  { date: new Date(2024, 4, 1), icon: "📈", title: "Marketing Push" },];<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Grid horizontal />  <Line dataKey="desktop" strokeWidth={2} />  <ChartMarkers items={markers} />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - Segment Selection

Click and drag to select a range

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Grid horizontal />  <Line dataKey="desktop" strokeWidth={2} />  <SegmentBackground />  <SegmentLineFrom />  <SegmentLineTo />  <ChartTooltip /></LineChart>

Click and drag on the chart to select a segment

Line Chart - Multiple Lines

Desktop vs mobile visitors over time

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Grid horizontal />  <Line dataKey="desktop" stroke="var(--chart-1)" strokeWidth={2} />  <Line dataKey="mobile" stroke="var(--chart-3)" strokeWidth={2} />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - X Axis

With labeled x-axis dates

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Grid horizontal />  <Line dataKey="desktop" strokeWidth={2} />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - X & Y Axis

With both horizontal grid and x-axis labels

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Grid fadeHorizontal={false} horizontal vertical />  <Line dataKey="desktop" strokeWidth={2} />  <XAxis />  <ChartTooltip /></LineChart>

Horizontal grid lines serve as the y-axis reference

Line Chart - Series Markers

Ring markers at each data point with the same config as Scatter

<LineChart data={chartData} xDataKey="date">  <Grid horizontal />  <Line    dataKey="visitors"    fadeEdges={false}    showMarkers    stroke="var(--chart-line-primary)"    strokeWidth={2.5}  />  <XAxis tickMode="data" />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - Loading

Shimmering grid, pulsing foreground segment, and shimmer label while data loads

import { LineChartLoading } from "@bklitui/ui/charts";<LineChartLoading  gridShimmerSync  label="Loading"  stroke="var(--foreground)"  strokeOpacity={0.5}/>// Uses curveNatural for the loading pulse path

Uses @bklit/shimmering-text for the label — installed with @bklit/line-chart

Line Chart - Loading (Sweep)

Diagonal shimmer sweeping across the skeleton line while data loads

<LineChartLoading loadingStyle="sweep" />

Set loadingStyle="sweep" on Line or LineChartLoading; defaults to the traveling pulse.

Line Chart - Dashed Tail

Curved dashed segment from a chosen index — useful for incomplete periods

<LineChart data={chartData} xDataKey="date">  <Grid horizontal />  <Line    dataKey="visitors"    dashArray="6,4"    dashFromIndex={5}    stroke="var(--chart-line-primary)"    strokeWidth={2.5}  />  <XAxis tickMode="data" />  <ChartTooltip /></LineChart>

The dashed tail follows the same curve and edge fade as the solid stroke

Line Chart - Left Y axis

Both series on the left scale with explicit Y-axis tick labels

<LineChart data={chartData} margin={{ top: 8, right: 8, bottom: 40, left: 56 }}>  <Grid horizontal />  <Line dataKey="desktop" strokeWidth={2.5} />  <Line dataKey="mobile" stroke="var(--chart-2)" strokeWidth={2.5} />  <YAxis yAxisId="left" />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - Left and right Y axes

Independent left and right scales (biaxial)

<LineChart data={chartData} margin={{ top: 8, right: 56, bottom: 40, left: 56 }}>  <Grid horizontal />  <Line dataKey="desktop" yAxisId="left" />  <Line dataKey="mobile" yAxisId="right" stroke="var(--chart-2)" />  <YAxis yAxisId="left" />  <YAxis yAxisId="right" orientation="right" />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - Profit/Loss

Sign-colored segments with a highlighted zero baseline and optional legend hover

import {  ProfitLossLine,  ProfitLossLegend,  ProfitLossLegendHoverProvider,  profitLossColor,  resolveProfitLossTooltipLabel,} from "@bklitui/ui/charts";<LineChart data={data}>  <Grid highlightRowValues={[0]} horizontal />  <Line dataKey="pnl" stroke="transparent" strokeWidth={0} showHighlight={false} />  <ProfitLossLegendHoverProvider hoveredIndex={legendHoveredIndex}>    <ProfitLossLine dataKey="pnl" />  </ProfitLossLegendHoverProvider>  <XAxis />  <ChartTooltip    indicatorColor={(point) => profitLossColor(point.pnl ?? 0)}    rows={(point) => [{      label: resolveProfitLossTooltipLabel(""),      value: point.pnl ?? 0,      color: profitLossColor(point.pnl ?? 0),    }]}  /></LineChart>

Legend below the chart, centered

Line Chart - Pattern Background

Diagonal pattern fill instead of grid lines

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Background />  <Line dataKey="desktop" strokeWidth={2} />  <XAxis />  <ChartTooltip /></LineChart>

Use Background instead of Grid — see /docs/utility/background

Line Chart - Dot Grid Background

Dot grid texture with edge fade

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Background pattern="dots" opacity={0.85} />  <Line dataKey="desktop" strokeWidth={2} />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - Reference Band

Horizontal Y band behind the series with dashed edges and bracket markers

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <ReferenceArea y1={160} y2={200} strokeStyle="dashed" showMarkers />  <Line dataKey="value" strokeWidth={2} />  <XAxis />  <ChartTooltip /></LineChart>

See /docs/utility/reference-area — tune bounds, fill, and markers in Studio

Line Chart - Pattern Reference Band

Pattern fill inside the band with colored Y-axis tick labels

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <ReferenceArea    y1={160}    y2={200}    pattern="diagonal"    patternColor="var(--chart-foreground-muted)"    axisLabelColor="var(--chart-1)"    fillOpacity={0.85}  />  <Line dataKey="value" strokeWidth={2} />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Line Chart - Trend Line

Dashed least-squares trend line drawn over the series

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Grid horizontal />  <Line dataKey="value" strokeWidth={2} />  <TrendLine dataKey="value" stroke="var(--chart-1)" />  <XAxis />  <ChartTooltip /></LineChart>

See /docs/utility/trend-line — place TrendLine after the series so it draws on top

Line Chart - Gradient Trend Line

Gradient stroke along the fit with faded ends

<LineChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <Grid horizontal />  <Line dataKey="value" strokeWidth={2} />  <TrendLine    dataKey="value"    strokeStyle="gradient"    gradientStart="var(--chart-3)"    gradientEnd="var(--chart-1)"    strokeWidth={2.5}    fadeEdges  />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month