CortexcnCortexcn

Background

Pattern fill for the plot area when grid lines are hidden, with presets, an edge fade, and an enter animation

Installation

ProPart of Cortexcn Pro

The source for background comes with a Cortexcn Pro license, along with every other chart and the website templates. Pick a license on the pricing page.

Usage

Use Background instead of Grid when you want a textured plot fill rather than reference lines. It must be a child of a cartesian chart (LineChart, AreaChart, BarChart, ScatterChart, CandlestickChart, ComposedChart, LiveLineChart, and other charts that provide chart context).

import {
  LineChart,
  Line,
  Background,
  ChartTooltip,
  XAxis,
} from "@/components/charts";

<LineChart data={data}>
  <Background pattern="diagonal" />
  <Line dataKey="value" />
  <XAxis />
  <ChartTooltip />
</LineChart>;

Background renders behind series layers. On time-series charts it sits outside the series clip reveal and fades in after the chart finishes loading.

Props

PropTypeDefaultDescription
pattern"diagonal" | "horizontal" | "vertical" | "cross" | "dots" | "circles" | "accent" | "none""diagonal"Pattern preset ("none" renders nothing)
colorstringvar(--chart-grid)Pattern stroke or dot color
scalenumber1Tile scale multiplier
strokeWidthnumberpreset defaultLine stroke width for line-based patterns
radiusnumberpreset defaultDot or circle radius for dots / circles
complementbooleanfalseAlternate tile fill for circle patterns
fillstring—Solid fill inside circles
dotFillbooleantrueDot grid only — hollow dots when false
tileBackgroundstring—Background color inside each pattern tile
showFillbooleantrueApply the pattern texture to the plot area
opacitynumber1Pattern fill opacity
fadeHorizontalbooleantrueFade pattern at left and right edges
fadeVerticalbooleantrueFade pattern at top and bottom edges
fadeHorizontalLengthnumber10Horizontal fade zone as % of plot width per edge (0–45)
fadeVerticalLengthnumber10Vertical fade zone as % of plot height per edge (0–45)

Patterns use @visx/pattern under the hood (PatternLines and PatternCircles).

Examples

Diagonal (default)

<LineChart data={data}>  <Background />  <Line dataKey="value" />  <XAxis />  <ChartTooltip /></LineChart>

Dot grid

<LineChart data={data}>  <Background pattern="dots" opacity={0.85} />  <Line dataKey="value" />  <XAxis />  <ChartTooltip /></LineChart>

Cross hatch

<LineChart data={data}>  <Background pattern="cross" scale={1.25} />  <Line dataKey="value" />  <XAxis />  <ChartTooltip /></ComponentShowcase>

No edge fade

<LineChart data={data}>  <Background pattern="horizontal" fadeHorizontal={false} fadeVertical={false} />  <Line dataKey="value" />  <XAxis />  <ChartTooltip /></LineChart>

Grid vs Background

Use Grid for reference lines. Use Background when you want a subtle pattern fill without ticks. They are typically mutually exclusive — pick one visual treatment for the plot area.