Composed 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 composed charts combining bars and lines
Installation
Usage
The composed chart is composible. <EvilComposedChart> is the container, and you compose only the parts you need — <Grid>, <XAxis>, <YAxis>, <Legend>, <Tooltip>, and one or more <Bar> and <Line> — as its children. Each <Bar> carries its own variant, glow, and isClickable, and each <Line> its own strokeVariant, curveType, glow, and isClickable, so a single chart can freely mix bar and line styles.
import {
EvilComposedChart,
Bar,
Line,
XAxis,
YAxis,
Grid,
Tooltip,
Legend,
Dot,
ActiveDot,
} from "@/components/evilcharts/charts/composed-chart";const chartConfig = {
revenue: {
label: "Revenue",
colors: { light: ["#3b82f6"], dark: ["#6A5ACD"] },
},
profit: {
label: "Profit",
colors: { light: ["#10b981"], dark: ["#34d399"] },
},
} satisfies ChartConfig;
<EvilComposedChart xDataKey="month" data={data} config={chartConfig}>
<Grid />
<XAxis dataKey="month" />
<YAxis />
<Legend isClickable />
<Tooltip />
<Bar dataKey="revenue" variant="gradient" isClickable />
<Line dataKey="profit" strokeVariant="dashed" isClickable>
<Dot variant="default" />
<ActiveDot variant="colored-border" />
</Line>
</EvilComposedChart>Interactive Selection
Add isClickable to any <Bar> or <Line> (and to <Legend>) to make those series selectable. Use the onSelectionChange callback on <EvilComposedChart> to handle selection events:
<EvilComposedChart
data={data}
config={chartConfig}
onSelectionChange={(selectedDataKey) => {
if (selectedDataKey) {
console.log("Selected:", selectedDataKey);
} else {
console.log("Deselected");
}
}}
>
<XAxis dataKey="month" />
<Legend isClickable />
<Tooltip />
<Bar dataKey="revenue" isClickable />
<Line dataKey="profit" isClickable />
</EvilComposedChart>Loading State
The composed 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.
Examples
Below are some examples of the composed chart with different variants. You can customize each <Bar> with a variant, and each <Line> with a strokeVariant, curveType, and other properties.
Gradient Colors
Bar Variants
Line Stroke Variants
Curve Types
Line Dots
The composed chart supports dots on lines. Compose a <Dot> for the resting marker and an <ActiveDot> for the marker that appears on hover, inside a <Line>. Available variants: default, border, colored-border.
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 a <Bar> to enable this feature.
Glowing Effects
Add a subtle glow effect to a series with the glow prop on a <Bar> or <Line>. Each glowing series renders its own scoped glow filter.
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, glow, and clickability.
A single line series. Each <Line /> is self-contained and generates its own color gradient and glow filter, so a chart can hold any number of lines — each with its own stroke, curve, glow, and clickability.
Point markers composed inside a <Line />. <Dot /> is the resting marker; <ActiveDot /> is the hovered marker. They render nothing on their own — the parent <Line /> reads their variant.
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.
The background grid lines. Defaults to horizontal-only dashed lines 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.