Charts

Copy-paste chart examples for every Bklit UI component.

Area Chart - Interactive

Revenue vs costs over 30 days with segment selection. Use the curve menu to compare @visx/curve on both areas.

import { curveMonotoneX } from "@visx/curve";<AreaChart aspectRatio="4 / 1" data={chartData}>  <Grid horizontal />  <Area curve={curveMonotoneX} dataKey="revenue" fill="var(--chart-line-primary)" fillOpacity={0.3} strokeWidth={2} />  <Area curve={curveMonotoneX} dataKey="costs" fill="var(--chart-line-secondary)" fillOpacity={0.2} strokeWidth={1.5} />  <SegmentBackground />  <SegmentLineFrom />  <SegmentLineTo />  <XAxis />  <ChartTooltip /></AreaChart>const chartData = Array.from({ length: 30 }, (_, i) => ({  date: new Date(2024, 0, i + 1),  revenue: Math.floor(8000 + Math.sin(i / 5) * 4000 + ((i * 11) % 2000)),  costs: Math.floor(5000 + Math.cos(i / 4) * 2000 + ((i * 7) % 1500)),}));

Click and drag to select a range. Hero curve menu uses the same Area `curve` prop for revenue and costs.

Area Chart - Value Labels

Dense 24-month, two-series area with shared, collision-aware value labels

<AreaChart data={chartData}>  <Grid horizontal />  <Area dataKey="desktop" showValue valueLabelMaxCount={5} />  <Area    dataKey="mobile"    fill="var(--chart-line-secondary)"    showValue    valueLabelMaxCount={5}  />  <XAxis />  <ChartTooltip /></AreaChart>

Both series share one label count. Resize to see labels adapt to the width and skip collisions.

Area Chart

Default area with gradient fill and smooth curve

<AreaChart data={chartData}>  <Grid horizontal />  <Area dataKey="desktop" fillOpacity={0.3} strokeWidth={2} />  <XAxis />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Step

Discrete step interpolation between points

import { curveStep } from "@visx/curve";<AreaChart data={chartData}>  <Grid horizontal />  <Area dataKey="desktop" curve={curveStep} fillOpacity={0.3} />  <XAxis />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Stacked

Layered areas comparing desktop and mobile

<AreaChart data={chartData}>  <Grid horizontal />  <Area    dataKey="desktop"    fill="var(--chart-line-primary)"    fillOpacity={0.3}  />  <Area    dataKey="mobile"    fill="var(--chart-line-secondary)"    fillOpacity={0.3}  />  <XAxis />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Gradient

Solid fill with gradientToOpacity control

<AreaChart data={chartData}>  <Area    dataKey="desktop"    fillOpacity={0.5}    gradientToOpacity={0.05}    strokeWidth={2}  />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - No Stroke

Softer look with the stroke line hidden

<AreaChart data={chartData}>  <Area    dataKey="desktop"    fillOpacity={0.5}    showLine={false}  />  <XAxis />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Fade Edges

Area fill fades at the left and right edges

<AreaChart data={chartData}>  <Grid horizontal />  <Area    dataKey="desktop"    fadeEdges    fillOpacity={0.3}    strokeWidth={2}  />  <XAxis />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Loading

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

import { AreaChartLoading } from "@bklitui/ui/charts";<AreaChartLoading  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/area-chart

Area Chart - Loading (Sweep)

Diagonal shimmer sweeping across the skeleton area while data loads

<AreaChartLoading loadingStyle="sweep" />

Set loadingStyle="sweep" on Area or AreaChartLoading; defaults to the traveling pulse.

Area Chart - Segment Selection

Click and drag to select a range

<AreaChart data={chartData}>  <Grid horizontal />  <Area dataKey="desktop" fillOpacity={0.3} strokeWidth={2} />  <SegmentBackground />  <SegmentLineFrom />  <SegmentLineTo />  <XAxis />  <ChartTooltip /></AreaChart>

Click and drag on the chart to select a segment

Area Chart - Pattern

Diagonal line pattern fill instead of gradient

<AreaChart data={chartData}>  <PatternLines    height={6}    id="area-pattern"    orientation={["diagonal"]}    stroke="var(--chart-1)"    strokeWidth={1}    width={6}  />  <PatternArea dataKey="desktop" fill="url(#area-pattern)" />  <Area dataKey="desktop" fillOpacity={0} strokeWidth={2} />  <XAxis />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Series Markers

Scatter-style ring markers at each point — same styling as Scatter

<AreaChart data={chartData} xDataKey="date">  <Grid horizontal />  <Area    dataKey="visitors"    fill="var(--chart-line-primary)"    fillOpacity={0.35}    showMarkers    markers={{ radius: 5, ringGap: 2, strokeWidth: 2 }}  />  <XAxis tickMode="data" />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Dashed Tail

Solid stroke through yesterday, dashed projection for the in-progress day

<AreaChart data={chartData} xDataKey="date">  <Grid horizontal />  <Area    dataKey="visitors"    dashArray="6,4"    dashFromIndex={5}    fill="var(--chart-line-primary)"    fillOpacity={0.35}    stroke="var(--chart-line-primary)"  />  <XAxis tickMode="data" />  <ChartTooltip /></AreaChart>

dashFromIndex is inclusive — the stroke dashes from that data row through the end

Area Chart - Left Y axis

Both series share the left scale with explicit Y-axis labels

<AreaChart data={chartData} margin={{ top: 8, right: 8, bottom: 40, left: 56 }}>  <Grid horizontal />  <Area dataKey="desktop" fillOpacity={0.3} strokeWidth={2} />  <Area dataKey="mobile" fill="var(--chart-2)" fillOpacity={0.3} strokeWidth={2} />  <YAxis yAxisId="left" />  <XAxis />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Left and right Y axes

Independent left and right scales (biaxial)

<AreaChart data={chartData} margin={{ top: 8, right: 56, bottom: 40, left: 56 }}>  <Grid horizontal />  <Area dataKey="desktop" yAxisId="left" fillOpacity={0.3} strokeWidth={2} />  <Area dataKey="mobile" yAxisId="right" fill="var(--chart-2)" fillOpacity={0.3} strokeWidth={2} />  <YAxis yAxisId="left" />  <YAxis yAxisId="right" orientation="right" />  <XAxis />  <ChartTooltip /></AreaChart>

Trending up by 5.2% this month

Area Chart - Pattern Background

Diagonal pattern fill instead of grid lines

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

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

Area Chart - Dot Grid Background

Dot grid texture with edge fade

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

Trending up by 5.2% this month

Area Chart - Reference Band

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

<AreaChart margin={{ top: 8, right: 8, bottom: 40, left: 8 }} data={chartData}>  <ReferenceArea y1={160} y2={220} strokeStyle="dashed" showMarkers />  <Area dataKey="desktop" fillOpacity={0.3} strokeWidth={2} />  <XAxis />  <ChartTooltip /></AreaChart>

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

Area Chart - Pattern Reference Band

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

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

Trending up by 5.2% this month

Area Chart - Trend Line

Dashed least-squares trend line drawn over the series

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

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

Area Chart - Gradient Trend Line

Gradient stroke along the fit with faded ends

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

Trending up by 5.2% this month