Composed Chart
Documentation Index
Fetch the complete documentation index at: /llms.txt. Use this file to discover all available pages before exploring further.
Our composed chart for combining bars and lines in one visualization.
Overview
Use a composed chart when bars and lines explain different measures over the same categories, such as revenue and conversion rate. Keep the number of series small so the mixed encodings remain easy to read.
Anatomy
ComposedChart owns the shared data, configuration, axes, selection, and loading state. Add Bar and Line parts for each measure, then compose optional grid, legend, tooltip, dot, and brush parts around them.
Accessibility
Canvas charts need a nearby text summary or data table when the exact values are important. Label the different measures clearly and do not use shape or color without an accompanying legend or text cue.
Installation
Usage
Our composed chart is composable. <ComposedChart> is the container, and every part hangs off it as a compound member, <ComposedChart.Grid>, <ComposedChart.XAxis>, <ComposedChart.YAxis>, <ComposedChart.Legend>, <ComposedChart.Tooltip>, and one or more <ComposedChart.Bar> and <ComposedChart.Line>, so a single import gives you the whole chart. Each <Bar> carries its own variant, glow, and isClickable, and each <Line> its own strokeVariant, curveType, glow, and isClickable, so one chart can freely mix bar and line styles.
import { ComposedChart, type ChartConfig } from "honestui/charts";const chartConfig = {
revenue: {
label: "Revenue",
colors: { light: ["#3b82f6"], dark: ["#6A5ACD"] },
},
profit: {
label: "Profit",
colors: { light: ["#10b981"], dark: ["#34d399"] },
},
} satisfies ChartConfig;
<ComposedChart xDataKey="month" data={data} config={chartConfig}>
<ComposedChart.Grid />
<ComposedChart.XAxis dataKey="month" />
<ComposedChart.YAxis />
<ComposedChart.Legend isClickable />
<ComposedChart.Tooltip />
<ComposedChart.Bar dataKey="revenue" variant="gradient" isClickable />
<ComposedChart.Line dataKey="profit" strokeVariant="dashed" isClickable>
<ComposedChart.Dot variant="default" />
<ComposedChart.ActiveDot variant="colored-border" />
</ComposedChart.Line>
</ComposedChart>ECharts renders to a <canvas>, so these children never mount as DOM, the root reads their props and compiles them into the ECharts option object. Same JSX, same presence semantics (omit a part and it doesn't render), same behavior; the children are just config, not live DOM nodes.
The config is the same contract as every Honest UI chart, each key maps a data key to a label and a per-theme colors array. See Chart Config for the full shape. Colors resolve from your CSS variables at runtime, so dark mode just works.
Canvas rendering has a few implementation details to keep in mind: multi-color bars run a vertical gradient through their color slots (horizontal-split and textured variants are single-color); the glow becomes a soft colored blur that follows each series' own color rather than an SVG filter; and the zoom brush is a themed mini chart driven by ECharts' native dataZoom rather than the custom HonestBrush.
Interactive Selection
Add isClickable to any <Bar>, <Line>, or <Legend> to make its series selectable, and handle events with the onSelectionChange callback on <ComposedChart>:
<ComposedChart
data={data}
config={chartConfig}
onSelectionChange={(selectedDataKey) => {
if (selectedDataKey) {
console.log("Selected:", selectedDataKey);
} else {
console.log("Deselected");
}
}}
>
<ComposedChart.XAxis dataKey="month" />
<ComposedChart.Legend isClickable />
<ComposedChart.Tooltip />
<ComposedChart.Bar dataKey="revenue" isClickable />
<ComposedChart.Line dataKey="profit" isClickable />
</ComposedChart>Loading State
Pass isLoading to show an animated skeleton of shimmering bars and a line, both revealed by one diagonal shimmer sweep. Use loadingBars to set how many bars it draws.
Examples
Examples of the composed chart with different variants. Customize each <Bar> with a variant, and each <Line> with a strokeVariant, curveType, and more.
Gradient Colors
Bar Variants
Line Stroke Variants
Curve Types
Line Dots
Inside a <Line>, compose a <Dot> for the resting marker and an <ActiveDot> for the one shown on hover. Available variants: default, border, colored-border.
Hover Highlight
Set enableHoverHighlight on a <Bar> to dim its other columns when you hover one, making a single data point easier to focus on. On canvas it uses ECharts' native emphasis, so nothing re-renders mid-hover.
Glowing Effects
Add the glow prop to a <Bar> or <Line> for a subtle glow. On canvas it's a soft colored blur that follows the series' own color along its length, staying faithful even on multi-stop gradients.
API Reference
The chart is composed of several parts; the props below are grouped by part. On canvas each part is config the root compiles.
The root container. It owns the data, shared selection state, loading skeleton, and optional native dataZoom brush. Everything visual is composed as its children and compiled into the ECharts option.
A single bar series. Each <Bar /> carries its own fill variant, radius, glow, and clickability, so a chart can hold any number of bars.
A single line series. Each <Line /> carries its own stroke, curve, glow, and clickability, so a chart can hold any number of lines.
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. Include <XAxis /> for the x-axis labels and <YAxis /> for the y-axis; omit either to hide it. Both hide automatically while loading.
The background grid lines. Include it to render the dashed horizontal split lines; omit it and they don't draw. Takes no props.
The hover tooltip. Include it to enable the tooltip; omit it and none shows. It reads the selection state and dims unselected series.
The series legend, rendered as HTML above the canvas. Include it to show the legend; omit it and none shows. With isClickable, each entry toggles selection of its series.
An optional zoom brush below the chart, a themed mini chart driven by ECharts' native dataZoom. Include <ComposedChart.Brush /> to render it; dragging the range filters the main chart.