Composed chart
Place one bar series and related line series on shared categorical and numeric scales.
- Requests
- Completed requests
- Requests
- 42
- Completed requests
- 31
View data table 6 rows
| Data point | Requests | Completed requests |
|---|---|---|
| Jan | 42 | 31 |
| Feb | 58 | 46 |
| Mar | 51 | 43 |
| Apr | 67 | 55 |
| May | 73 | 61 |
| Jun | 78 | 68 |
Installation
bunx --bun shadcn@latest add https://apple-ui-eduardo.vercel.app/r/composed-chart.jsonThe registry includes the shared styles and dependencies. Import @/components/apple-ui/styles.css in your root layout once. For the package route, use the installation guide.
Usage
"use client";
import { ComposedChart } from "@eduardoul/apple-ui";
const data = [
{ label: "Jan", requests: 42, completed: 31 },
{ label: "Feb", requests: 58, completed: 46 },
{ label: "Mar", requests: 51, completed: 43 },
{ label: "Apr", requests: 67, completed: 55 },
{ label: "May", requests: 73, completed: 61 },
];
export function Example() {
return (
<ComposedChart
title="Requests and completed requests"
description="Synthetic monthly counts"
data={data}
series={[
{ key: "requests", label: "Requests" },
{ key: "completed", label: "Completed requests" },
]}
/>
);
}Package imports use @eduardoul/apple-ui. Registry imports use @/components/apple-ui. Add "use client" to files that use state or event handlers.
API reference
| Property | Type | Default |
|---|---|---|
| data | ChartDatum[] | required |
| series | ChartSeries[] | required |
| labelKey | string | label |
| title | string | required |
| description | string | undefined |
| height | number | component default |
| loading | boolean | false |
| error | string | undefined |
| emptyMessage | string | No data to display. |
| showTable | boolean | true |
| compact | boolean | false |
| valueFormatter | (value: number) => string | localized number |
| className | string | undefined |
| style | React.CSSProperties | undefined |
Use className and style to customize the component. The package includes full TypeScript definitions for its supported element properties and refs.
Design guidance
- Use the first series for bars and the remaining series for lines.
- Compose measures only when one shared scale makes both readable and honest.
- Split the view when units or ranges differ enough that one series would appear flat or exaggerated.
Accessibility
Give the chart a descriptive title and explain its units. Select a data point to read its values, or open the data table for the full dataset. Labels and values accompany color, and the chart adapts to reduced motion and appearance preferences. Test long labels, touch input and keyboard navigation with your own data.
Library styles support reduced motion, reduced transparency, increased contrast and forced colors. Read the accessibility foundation for the checks your application still needs.