# ComposedChart Combine bar, line, and area series on one category axis. Use grouped, stacked, or percent bars according to the comparison. [Interactive guide](/docs/components/composedchart) · Forge 3.2.0 Use the API for your installed version. Run `npx --no-install wss3-forge api --json` inside the project. ## Implementation guidance ### When to use it Use ComposedChart when one category comparison needs a distinct mark for the measurements and their target or trend. ### How to compose it Assign each series a mark. Use matching units on the shared axis. For percent bars, express overlaid line or area values and thresholds in percentage points. ### What to verify Compare the readout with source data, including missing values. Verify that positive and negative shares are understood separately in percent mode. ## Usage ```tsx import { ComposedChart } from 'wss3-forge' import type { ComposedChartProps, ChartDatum } from 'wss3-forge' ``` - Specify a mark for each series. Use bars to compare category totals and a line to show a target or trend measured in the same unit. - Grouped bars sit side by side. Stacked bars total the positive values above zero and the negative values below zero. - Percent bars show share by category. Positive values total 100% independently of negative values, whose shares total -100%. The readout and optional showTable disclosure include the original values and their shares. - When combining percent bars with a line or area, express that additional series and any thresholds in percentage points. - Use null to record missing data and zero for a measurement whose value is zero. ```tsx ``` ## Runnable examples ### Measured orders and target line ```tsx import { ComposedChart } from 'wss3-forge' import type { ChartDatum } from 'wss3-forge' const service = [ { label: 'Jan', values: { actual: 68, planned: 75 } }, { label: 'Feb', values: { actual: 72, planned: 75 } }, { label: 'Mar', values: { actual: null, planned: 80 } }, { label: 'Apr', values: { actual: 87, planned: 80 } }, ] satisfies ChartDatum[] export default function Example() { return () } ``` ### Signed stacks with refunds ```tsx import { ComposedChart } from 'wss3-forge' import type { ChartDatum, ComposedChartProps } from 'wss3-forge' const movements = [ { label: 'Jan', values: { store: 240, online: 160, refunds: -80 } }, { label: 'Feb', values: { store: 180, online: 220, refunds: -40 } }, { label: 'Mar', values: { store: 140, online: 260, refunds: null } }, { label: 'Apr', values: { store: 0, online: 0, refunds: 0 } }, ] satisfies ChartDatum[] const movementSeries: ComposedChartProps['series'] = [ { key: 'store', label: 'Store', kind: 'bar', unit: 'USD' }, { key: 'online', label: 'Online', kind: 'bar', unit: 'USD' }, { key: 'refunds', label: 'Refunds', kind: 'bar', unit: 'USD' }, ] export default function Example() { return () } ``` ### 100% stacks by sales channel ```tsx import { ComposedChart } from 'wss3-forge' import type { ChartDatum, ComposedChartProps } from 'wss3-forge' const movements = [ { label: 'Jan', values: { store: 240, online: 160, refunds: -80 } }, { label: 'Feb', values: { store: 180, online: 220, refunds: -40 } }, { label: 'Mar', values: { store: 140, online: 260, refunds: null } }, { label: 'Apr', values: { store: 0, online: 0, refunds: 0 } }, ] satisfies ChartDatum[] const movementSeries: ComposedChartProps['series'] = [ { key: 'store', label: 'Store', kind: 'bar', unit: 'USD' }, { key: 'online', label: 'Online', kind: 'bar', unit: 'USD' }, { key: 'refunds', label: 'Refunds', kind: 'bar', unit: 'USD' }, ] export default function Example() { return () } ``` ## Root package API ### ComposedChart Combine bar, line, and area series on one category axis. Use grouped, stacked, or percent bars according to the comparison. Props type: `ComposedChartProps` - `series` — `readonly (ChartSeries & Required>)[]` Series with an explicit bar, line, or area mark. - `className?` — `string` - `style?` — `CSSProperties` - `title` — `string` - `width?` — `number | string` - `data` — `readonly ChartDatum[]` Ordered categories with values keyed by series. - `summary?` — `string` - `headerAction?` — `ReactNode` Place a control beside the caption; it wraps beneath the caption on narrow surfaces. - `domain?` — `ChartDomain` - `barLayout?` — `ChartBarLayout` Options `"grouped"`, `"stacked"`, `"percent"`. Place bars side by side, stack values by sign, or normalize each side to 100%. - `interpolation?` — `'linear' | 'step'` Default `'linear'`. Options `"linear"`, `"step"`. Connect line and area points directly or step halfway between categories. - `areaFill?` — `'solid' | 'gradient'` Default `'solid'`. Options `"solid"`, `"gradient"`. Fill area marks with a constant tint or a vertical fade. - `thresholds?` — `readonly ChartThreshold[]` - `xAxis?` — `ChartCategoryAxisOptions` - `yAxis?` — `ChartValueAxisOptions` - `height?` — `number` - `showLegend?` — `boolean` - `showTooltip?` — `boolean` - `showTable?` — `boolean` Default `false`. Offer a disclosure with the source values. - `emptyLabel?` — `string` - `categoryLabel?` — `string` ## Related types ```ts export interface ChartSeries { key: string label?: string kind?: 'bar' | 'line' | 'area' color?: string unit?: string formatValue?: (value: number) => string } export interface ChartDatum { label: string values: Readonly> } export type ChartDomain = readonly [min: number, max: number] export type ChartBarLayout = 'grouped' | 'stacked' | 'percent' export interface ChartThreshold { value: number label: string color?: string } export interface ChartCategoryAxisOptions { label?: string showLabels?: boolean formatLabel?: (label: string) => string } export interface ChartValueAxisOptions { label?: string showLabels?: boolean showGrid?: boolean tickCount?: number formatValue?: (value: number) => string } export interface ComposedChartProps extends Omit { series: readonly (ChartSeries & Required>)[] } export interface CartesianChartProps { data: readonly ChartDatum[] series: readonly ChartSeries[] title: string summary?: string /** Place a control beside the caption; it wraps beneath the caption on narrow surfaces. */ headerAction?: ReactNode domain?: ChartDomain /** Place bars side by side, stack values by sign, or normalize each side to 100%. */ barLayout?: ChartBarLayout /** Connect line and area points directly or step halfway between categories. @default 'linear' */ interpolation?: 'linear' | 'step' /** Fill area marks with a constant tint or a vertical fade. @default 'solid' */ areaFill?: 'solid' | 'gradient' thresholds?: readonly ChartThreshold[] xAxis?: ChartCategoryAxisOptions yAxis?: ChartValueAxisOptions width?: number | string height?: number showLegend?: boolean showTooltip?: boolean /** Offer a disclosure with the source values. @default false */ showTable?: boolean emptyLabel?: string categoryLabel?: string className?: string style?: CSSProperties } ```