Charts

Copy-paste chart examples for every Bklit UI component.

Profit/Loss Line

Sign-colored segments with a highlighted zero baseline and 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><ProfitLossLegend align="center" />

Legend below the chart, centered

Profit/Loss Line - Left Y axis

Sign-colored line with a left Y-axis scale and zero baseline

<LineChart data={data} margin={{ top: 40, right: 40, bottom: 40, left: 56 }}>  <Grid highlightRowValues={[0]} horizontal />  <Line dataKey="pnl" stroke="transparent" strokeWidth={0} showHighlight={false} />  <ProfitLossLine dataKey="pnl" />  <YAxis yAxisId="left" />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Profit/Loss Line - Pattern Background

Diagonal pattern fill instead of grid lines

<LineChart data={data}>  <Background />  <Line dataKey="pnl" stroke="transparent" strokeWidth={0} showHighlight={false} />  <ProfitLossLine dataKey="pnl" />  <XAxis />  <ChartTooltip /></LineChart>

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

Profit/Loss Line - Dot Grid Background

Dot grid texture with edge fade

<LineChart data={data}>  <Background pattern="dots" opacity={0.85} />  <Line dataKey="pnl" stroke="transparent" strokeWidth={0} showHighlight={false} />  <ProfitLossLine dataKey="pnl" />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month

Profit/Loss Line - Reference Band

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

<LineChart data={data}>  <ReferenceArea y1={-200} y2={200} strokeStyle="dashed" showMarkers />  <Line dataKey="pnl" stroke="transparent" strokeWidth={0} showHighlight={false} />  <ProfitLossLine dataKey="pnl" />  <XAxis />  <ChartTooltip /></LineChart>

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

Profit/Loss Line - Pattern Reference Band

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

<LineChart data={data}>  <ReferenceArea    y1={-200}    y2={200}    pattern="diagonal"    patternColor="var(--chart-foreground-muted)"    axisLabelColor="var(--chart-1)"    fillOpacity={0.85}  />  <Line dataKey="pnl" stroke="transparent" strokeWidth={0} showHighlight={false} />  <ProfitLossLine dataKey="pnl" />  <XAxis />  <ChartTooltip /></LineChart>

Trending up by 5.2% this month