Bar Chart
Documentation Index
Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.
Simple static & beautifully designed bar charts
Installation
Usage
The bar chart is composible. <EvilBarChart> is the container, and you compose only the parts you need — <Grid>, <XAxis>, <YAxis>, <Legend>, <Tooltip>, and one or more <Bar> — as its children. Each <Bar> carries its own variant, radius, glowing, bufferBar, and isClickable, so a single chart can mix fill styles and make only some series interactive.
import {
EvilBarChart,
Bar,
XAxis,
YAxis,
Grid,
Tooltip,
Legend,
} from "@/components/evilcharts/charts/bar-chart";<EvilBarChart data={data} config={chartConfig} stackType="default">
<Grid />
<XAxis dataKey="month" />
<Legend isClickable />
<Tooltip />
<Bar dataKey="desktop" variant="default" isClickable />
<Bar dataKey="mobile" variant="hatched" isClickable />
</EvilBarChart>Interactive Selection
Add isClickable to any <Bar> (and to <Legend>) to make those series selectable. Use the onSelectionChange callback on <EvilBarChart> to handle selection events:
<EvilBarChart
data={data}
config={chartConfig}
onSelectionChange={(selectedDataKey) => {
if (selectedDataKey) {
console.log("Selected:", selectedDataKey);
} else {
console.log("Deselected");
}
}}
>
<XAxis dataKey="month" />
<Legend isClickable />
<Tooltip />
<Bar dataKey="desktop" variant="default" isClickable />
<Bar dataKey="mobile" variant="default" isClickable />
</EvilBarChart>Loading State
The bar chart supports loading state with a shimmer animation. You can pass the isLoading prop to the chart to show the loading state while your data is being fetched.
Buffer Bar
When a <Bar> has bufferBar set, its last data point is rendered with a diagonal lines (hatched) pattern while the rest stay solid. This is useful for indicating projected, estimated, or incomplete data at the end of a series — commonly seen in financial charts and forecasting dashboards.
Examples
Below are some examples of the bar chart with different variants. Each <Bar> carries its own variant, and the chart-wide stackType and layout shape the rest.
Hover Highlight
The hover highlight feature dims other bars when you hover over a bar, making it easier to focus on specific data points. Set the enableHoverHighlight prop on each <Bar> to enable this feature.
Gradient Colors
Bar Variants
Stack Types
Horizontal Layout
Use layout="horizontal" on <EvilBarChart> to display bars horizontally. Compose both <XAxis /> (values) and <YAxis dataKey="month" /> (categories). See the preview at the top of this page.
Glowing Bars
API Reference
The chart is composed of several parts. The props below are grouped by the component they belong to.
The root container. It owns the data, the shared selection state, the loading skeleton, and the optional brush. Everything visual is composed as its children.
A single bar series. Each <Bar /> is self-contained and generates its own gradient/pattern definitions, so a chart can hold any number of bars — each with its own variant, radius, glow, and clickability.
The category and value axes. Both ship with the chart's flat default styling and forward every Recharts axis prop, so dataKey, tickFormatter, tickMargin, etc. pass straight through. They are hidden automatically while the chart is loading, and each resolves its axis 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 based on the chart layout, and forwards every Recharts CartesianGrid prop.
The hover tooltip. It reads the chart's selection state so its content dims unselected series.
The series legend. When isClickable is set, each entry toggles selection of its series.