CortexcnCortexcn

Reference Area

Shaded Y band for target ranges and thresholds on cartesian charts, with a solid or pattern fill, dashed edges, and Y-axis tick coloring

Installation

ProPart of Cortexcn Pro

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

Usage

ReferenceArea draws a horizontal band between two Y data values. Place it as a child of any cartesian chart (LineChart, AreaChart, BarChart, ScatterChart, CandlestickChart, ComposedChart, LiveLineChart). It renders in the underlay layer — above grid and background, behind series.

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

<LineChart data={data}>
  <Grid horizontal />
  <ReferenceArea y1={160} y2={220} strokeStyle="dashed" showMarkers />
  <Line dataKey="value" />
  <XAxis />
  <ChartTooltip />
</LineChart>;

Omit y1 or y2 to extend the band to the top or bottom of the plot. Use axisLabelColor to tint Y-axis tick labels whose values fall inside the band.

Props

PropTypeDefaultDescription
y1number—Lower Y data bound (extends to plot top when omitted)
y2number—Upper Y data bound (extends to plot bottom when omitted)
x1Date | number—Starting X data coordinate (extends to plot left when omitted)
x2Date | number—Ending X data coordinate (extends to plot right when omitted)
yAxisIdstring | number"left"Y-scale group id
fillstringmuted mix on --chart-foreground-mutedSolid fill when pattern is "none"
fillOpacitynumber1Fill opacity
patternPattern preset id"none"Pattern fill inside the band
patternColorstring—Pattern stroke or tile color
patternScalenumber—Pattern tile scale
patternStrokeWidthnumber—Line stroke width for line-based patterns
patternRadiusnumber—Dot or circle radius for dots / circles
patternComplementboolean—Alternate tile fill for circle patterns
patternFillstring—Solid fill inside circles
patternDotFillboolean—Dot grid only — hollow dots when false
patternTileBackgroundstring—Background color inside each pattern tile
strokestring—Edge line color
strokeWidthnumber1Edge line width
strokeStyle"solid" | "dashed""solid"Edge line style
strokeDasharraystring"4,4"Dash array when strokeStyle is "dashed"
fadeEdgesbooleantrueFade fill and edges at left/right
fadeEdgesLengthnumber10Horizontal fade zone as % of plot width per edge (0–45)
axisLabelColorstring—Y-axis tick label color for values inside the band
showMarkersbooleanfalseInward bracket markers at the horizontal center
markerColorstring—Bracket marker color
markerSizenumber—Bracket marker size
ifOverflow"hidden" | "visible""hidden"Clip band to the plot when bounds exceed the domain

Pattern presets match Background (diagonal, dots, cross, …).

Examples

Dashed band with markers

<LineChart data={data}>  <Grid horizontal />  <ReferenceArea y1={160} y2={220} strokeStyle="dashed" showMarkers />  <Line dataKey="value" />  <XAxis />  <ChartTooltip /></LineChart>

Pattern fill with axis labels

<LineChart data={data}><Grid horizontal /><ReferenceArea  y1={160}  y2={200}  pattern="diagonal"  patternColor="oklch(0.76 0.144 180.392 / 0.17)"  patternScale={0.75}  patternStrokeWidth={1.5}  stroke="oklch(0.841 0.142 159.667 / 0.49)"  axisLabelColor="oklch(0.795 0.152 164.722)"/><Line dataKey="value" /><XAxis /><ChartTooltip /></LineChart>

Colored markers

<LineChart data={data}><Grid horizontal /><ReferenceArea  y1={160}  y2={220}  stroke="var(--chart-1)"  strokeStyle="dashed"  showMarkers  markerColor="var(--chart-1)"/><Line dataKey="value" /><XAxis /><ChartTooltip /></LineChart>

See Reference Band examples on each cartesian chart gallery: line, area, bar, composed, scatter, candlestick, live line, and profit/loss line.