Docs/Charts/ComposedChart

ComposedChart

ComposedChart is the cartesian container for mixed Area, Bar, and Line series in a single chart. It owns the layout, scales, and interaction state; children like XAxis, CartesianGrid and Tooltip register themselves into it.

import {
  ComposedChart,
  Area,
  Bar,
  Line,
  XAxis,
  YAxis,
  CartesianGrid,
  Tooltip,
} from "solid-recharts";

<ComposedChart width={500} height={300} data={data}>
  <CartesianGrid strokeDasharray="3 3" />
  <XAxis dataKey="name" />
  <YAxis />
  <Tooltip />
  <Bar dataKey="amt" fill="#8884d8" />
  <Area type="monotone" dataKey="uv" stroke="#82ca9d" fill="#82ca9d" />
  <Line type="monotone" dataKey="pv" stroke="#ffc658" />
</ComposedChart>;
ComposedChart
composed-basic.tsxOpen ↗
Loading source...

Props

PropTypeDefaultDescription
dataobject[]—Source data array, one entry per x position
width, heightnumber—Fixed size (omit when inside ResponsiveContainer)
layout"horizontal" | "vertical""horizontal"Direction of the independent axis
margin{ top, right, bottom, left }{ 5, 5, 5, 5 }Space around the plot area
syncIdstring—Sync tooltip/brush across charts sharing the id
onClick, onMouseMove, …function—Chart-level mouse events with the active payload

All other recharts ComposedChart props are supported; see the recharts ComposedChart docs for the full matrix.

Notes

  • Add any combination of <Bar>, <Area>, and <Line> children in any order.
  • All series share the same x and y axes unless you assign custom xAxisId/yAxisId.
  • Set stackId on two or more Bar or Area children to stack them.
  • Set syncId on two charts to mirror tooltips and brushes between them.

See also

  • Area — fill series with dots and labels
  • Bar — column series with shapes and stacking
  • Line — line series with curves and customization
  • XAxis · YAxis