Brush
Documentation Index
Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.
A zoom brush that filters the chart down to a draggable range of the data.
Usage
Add <EvilAreaChart.Brush /> as a child of the chart root. Its presence renders the brush footer โ a miniature of the full dataset with a draggable selection window over it. Narrowing that window filters the main chart to the selected range; the miniature always keeps showing everything, so you never lose your place.
Set xDataKey on the root so the handles can label themselves with the value under each edge.
import { EvilAreaChart } from "@/components/evilcharts/charts/recharts-area-chart";
<EvilAreaChart data={data} config={chartConfig} xDataKey="date">
<EvilAreaChart.XAxis dataKey="date" />
<EvilAreaChart.Brush formatLabel={(value) => String(value)} />
<EvilAreaChart.Area dataKey="desktop" variant="gradient" />
</EvilAreaChart>;Example
Drag either handle to resize the range, or drag the selected region itself to pan without changing its width. Handle labels fade in while the pointer is over the brush. Dragging is pointer-based, so mouse, touch, and pen all work.
Supported Charts
The brush is available on the cartesian charts โ EvilAreaChart, EvilLineChart, EvilBarChart, and EvilComposedChart. Attach it exactly the same way on each:
<EvilLineChart.Brush />
<EvilBarChart.Brush />
<EvilComposedChart.Brush />The miniature mirrors the chart it belongs to. Area and composed charts draw filled areas, line charts draw strokes only, and bar charts draw rounded bars โ and it inherits the parent chart's curveType, stacking, bar radius, and series colors, so the footer always reads as the same chart in small.
The brush is hidden while the chart is in its loading state, and it never renders for the non-cartesian charts (pie, radar, radial, sankey), which have no continuous axis to zoom.
Reacting to the Range
Filtering the chart is automatic โ the root already slices its data to the selection. Pass onChange when something outside the chart needs to follow along, such as a heading that reports the visible window:
const [range, setRange] = useState({ startIndex: 0, endIndex: data.length - 1 });
<EvilAreaChart data={data} config={chartConfig} xDataKey="date">
<EvilAreaChart.Brush onChange={setRange} />
<EvilAreaChart.Area dataKey="desktop" variant="gradient" />
</EvilAreaChart>;
// data[range.startIndex].date โ data[range.endIndex].dateonChange fires with data indices, not values, so look the labels up on your own rows.
API Reference
Composed as a child of the chart root. It renders nothing itself โ its presence turns the brush footer on, and its props configure it.