Bar Chart
Documentation Index
Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.
Static, beautifully designed bar charts
Installation
Usage
The bar chart is composible. <EvilBarChart> is the container, and every part hangs off it as a compound member — <EvilBarChart.Grid>, <EvilBarChart.XAxis>, <EvilBarChart.YAxis>, <EvilBarChart.Legend>, <EvilBarChart.Tooltip>, and one or more <EvilBarChart.Bar> — as children. Each <Bar> sets its own variant, radius, glowing, bufferBar, and isClickable, so one chart can mix fill styles and make only some series interactive.
import { EvilBarChart } from "@/components/evilcharts/charts/recharts-bar-chart";
import { type ChartConfig } from "@/components/evilcharts/ui/recharts-chart";<EvilBarChart data={data} config={chartConfig} stackType="default">
<EvilBarChart.Grid />
<EvilBarChart.XAxis dataKey="month" />
<EvilBarChart.Legend isClickable />
<EvilBarChart.Tooltip />
<EvilBarChart.Bar dataKey="desktop" variant="default" isClickable />
<EvilBarChart.Bar dataKey="mobile" variant="hatched" isClickable />
</EvilBarChart>Interactive Selection
Add isClickable to any <Bar> (and <Legend>) to make its series selectable, then handle events with the onSelectionChange callback on <EvilBarChart>:
<EvilBarChart
data={data}
config={chartConfig}
onSelectionChange={(selectedDataKey) => {
if (selectedDataKey) {
console.log("Selected:", selectedDataKey);
} else {
console.log("Deselected");
}
}}
>
<EvilBarChart.XAxis dataKey="month" />
<EvilBarChart.Legend isClickable />
<EvilBarChart.Tooltip />
<EvilBarChart.Bar dataKey="desktop" variant="default" isClickable />
<EvilBarChart.Bar dataKey="mobile" variant="default" isClickable />
</EvilBarChart>Loading State
Pass isLoading to show a shimmer skeleton while data loads.
Buffer Bar
With bufferBar set, a <Bar>'s last data point renders as a hatched pattern while the rest stay solid — handy for flagging projected or incomplete data, as in financial and forecasting charts.
Examples
Examples across different variants. Each <Bar> sets its own variant; the chart-wide stackType and layout shape the rest.
Hover Highlight
Set enableHoverHighlight on a <Bar> to dim the other bars on hover, keeping focus on one series.
Gradient Colors
Bar Variants
Stack Types
Horizontal Layout
Set layout="horizontal" on <EvilBarChart> to lay bars sideways. The <YAxis> then shows categories and the <XAxis> shows values — pass a tickFormatter to <YAxis> to format categories.
Glowing Bars
API Reference
The chart has several parts. Props below are grouped by component.
The root container. It owns the data, shared selection state, loading skeleton, and optional brush — everything visual is composed as its children.
A single bar series. Each <Bar /> is self-contained and generates its own gradient/pattern defs, so a chart can hold any number — each with its own variant, radius, glow, and clickability.
The category and value axes. Both use the chart's flat default styling and forward every Recharts axis prop, so dataKey, tickFormatter, tickMargin, etc. pass straight through. They hide automatically while the chart loads, and each resolves its type from the chart layout — categorical or numeric — unless you set type explicitly.
The background grid lines. Defaults to dashed lines aligned to the value axis for the current layout, and forwards every Recharts CartesianGrid prop.
The hover tooltip. It reads the chart's selection state, dimming unselected series.
The series legend. When isClickable is set, each entry toggles selection of its series.
An optional zoom brush below the chart. Include <EvilBarChart.Brush /> to render it; dragging the range filters the main chart.