Skip to content

Chart

The Chart component renders line, bar, area, and pie charts from a single data shape: each row has a label (category or slice name) and one or more numeric series keys. Colours map series or slice names to design-system colour tokens (red, blue, green, and so on).

Import from the framework package and pass type, data, and colors (or rely on automatic colours derived from the first row’s keys).

Sales vs Revenue Trend

new

old

revenue

sales

Loading Code Block...
  • data: Array of objects. Each object must include label: string. Every other enumerable key should be a number (one or more series for cartesian charts, or typically a single metric key for pie slices).
  • colors: Optional map from series or slice name → token: default, red, orange, blue, green, purple, neutral. If omitted, the implementation assigns colours from the default palette in key order.

Use type to select the visualisation. Line, bar, and area charts share the bordered card layout with an optional header (title, top legend, filter) and footer (bottom legend, footer copy).

Use the dropdown to switch chart type.

Sales vs Revenue Trend

new

old

revenue

sales

Loading Code Block...

For type="bar", variant chooses grouped (side-by-side) or stacked bars. Both frameworks honour this prop.

Use the dropdown to switch bar variant.

Sales vs Revenue Trend

new

old

revenue

sales

Loading Code Block...

For type="line" and type="area", lineType sets interpolation: linear, step, or curved (mapped to Recharts “natural” curves on the React side).

Use the dropdown to switch lineType.

Sales vs Revenue Trend

new

old

revenue

sales

Loading Code Block...

For type="pie", arrangement controls how the pie legend is laid out: horizontal or vertical. (This is separate from pieType.)

Use the dropdown to switch arrangement.

Browser Market Share

Chrome275
Safari200
Firefox187
Edge173
Other90
Loading Code Block...

pieType selects default (filled pie), donut, or stacked.

Use the dropdown to switch pieType.

Browser Market Share

Chrome275
Safari200
Firefox187
Edge173
Other90
Loading Code Block...

For pieType="donut" (and stacked pie where supported), centerTitle and centerSubtext render text in the centre.

Browser Usage Distribution

Total Users
2000
Chrome275
Safari200
Firefox187
Edge173
Other90
Loading Code Block...

A dropdown can appear in the header when you supply filterOptions.

Sales vs Revenue Trend

new

old

revenue

sales

Loading Code Block...

footerTitle and subtext render copy in the footer region when the footer is shown. The footer also appears when legendPosition="bottom" and the legend is enabled, so the legend and footer text can appear together.

Sales vs Revenue Trend

Total revenue

Combined across all regions for the selected period.

new

old

revenue

sales

Loading Code Block...
  • Provide a concise title so the chart context is clear in the document outline.
  • For pie charts, label values become slice names — use meaningful names, not only codes.
  • Tooltips are visual; do not rely on them as the only place where critical values appear if you must meet strict textual alternatives (consider a supplementary table for high-stakes data).

PropsDefaultTypeDescription
typeReact: required in practice. Vue: `'line'`'line' | 'bar' | 'area' | 'pie'Selects the chart implementation. Pie uses a different shell and legend behaviour than cartesian types.
data-Array<{ label: string; [key: string]: number }>Required. One object per category or slice; `label` is required. Other keys are numeric series (cartesian) or typically one metric column (pie).
colorsAuto from default palette per key orderRecord<string, ColorToken>Maps each series or slice name to a token: `default`, `red`, `orange`, `blue`, `green`, `purple`, `neutral`.
PropsDefaultTypeDescription
title-stringHeading in the header row when the header is shown. In React the title is rendered inside the pie card; in Vue it is rendered above the pie via the shared `<ChartHeader>`.
showLegend`true`booleanToggles legend visibility. For cartesian charts, the legend is rendered via the shared header/footer; pie charts handle the legend inside the pie implementation.
legendPosition`'top'`'top' | 'bottom' | 'left' | 'right'Where the legend renders relative to the chart. Cartesian charts only wire `top` / `bottom` in both frameworks — `left` / `right` produce no legend. For pie, React applies `flex-row` / `flex-row-reverse` for side placements; Vue ignores side positions and always falls back to `arrangement`.
arrangement`'vertical'`'horizontal' | 'vertical'Pie legend layout. Not used for line/bar/area shared legend strip. `arrangement="vertical"` also caps the pie at `max-w-[400px]` in both frameworks (Vue applies it on the outer shell, React on the inner pie card).
filterOptionsReact: `undefined`. Vue: `[]`{ label: string; value: string | number }[]Options for the header dropdown. The `value` field accepts either `string` or `number` in both frameworks.
onFilterChange-(value: string | number | (string | number)[]) => voidRequired alongside `filterOptions` — without it the dropdown does not render. The callback receives the option's `value` (preserving its original `string | number` type).
filter-React.ReactNodeReplaces the built-in dropdown with arbitrary JSX (forwarded to `<ChartHeader>`). Vue has **no equivalent** today — `<slot name="filter">` is not wired in `Chart.vue` / `ChartHeader.vue` and any slot content is silently dropped.
filterPosition`'right'`'left' | 'right'Aligns the header row: `right` pushes title and filter to opposite ends on wide screens.
PropsDefaultTypeDescription
showTooltip`true`booleanEnables hover tooltips. Tooltip DOM, animation, and breakpoints differ between frameworks because React renders via Recharts and Vue renders via ApexCharts.
PropsDefaultTypeDescription
footerTitle-stringPrimary line in the footer when the footer region is visible.
subtext-stringSecondary line in the footer (description or caption).
PropsDefaultTypeDescription
lineType`'linear'`'linear' | 'step' | 'curved'Line/area interpolation. Ignored for type="bar" and type="pie". React maps `curved` to Recharts' "natural" curve; Vue maps it to ApexCharts' smooth curve.
variant`'grouped'`'grouped' | 'stacked'For type="bar": grouped (side-by-side) vs stacked bars (Recharts `stackId="a"` in React, ApexCharts `stacked: true` in Vue). For type="area" the prop is a no-op in both frameworks: React's `AreaChart` does not accept `variant`, and Vue's `AreaLineChart` ignores the `stacked` prop forwarded from `Chart.vue`. Ignored entirely for type="line" and type="pie".
PropsDefaultTypeDescription
pieType`'default'`'default' | 'donut' | 'stacked'Pie geometry style. Both frameworks render the same visual pattern: filled pie / donut with centre text / stacked secondary pie.
centerTitle-stringCentre label for donut (and the React stacked-pie secondary branch). Rendered only when `pieType === 'donut'`.
centerSubtext-stringSecondary centre line, often a total or subtitle.