Skip to content
Browse documentation
whisk/ui

Chart

Render supported data visualizations from structured data.

Overview

Chart renders a small, read-only bar, line, or pie dataset with hover and keyboard value disclosure plus an exact accessible data table. It is not a general charting engine, data-fetching layer, or application state manager.

Use when

A small, bounded dataset benefits from a visual comparison and the exact values remain available in the built-in data table.

Use instead

Use Table when scanning or copying exact values is the main task. Use a specialised charting library when you need custom axes, formatters, annotations, data fetching, drill-down, or application-owned chart state.

Usage

Weekly signups

Signups peaked on Tuesday.

Weekly signups
LabelSignups
Mon12
Tue18
Wed15
import { Chart, type ChartData } from "@smoothie-framework/whisk-react";

const data = {
  type: "bar",
  labels: ["Mon", "Tue", "Wed"],
  datasets: [{ label: "Signups", data: [12, 18, 15] }],
} satisfies ChartData;

<Chart title="Weekly signups" description="Signups peaked on Tuesday." data={data} />

Examples

Start with a bounded comparison

Chart data is an ordered snapshot. Each dataset needs exactly one finite value for every label; Chart validates the shape before rendering the plot and exact-value table.

Weekly signups

Signups peaked on Thursday.

Weekly signups (Signups)
DaySignups
Mon12
Tue18
Wed15
Thu21
Fri17
import { Chart, type ChartData } from "@smoothie-framework/whisk-react";

const weeklySignups = {
  type: "bar",
  labels: ["Mon", "Tue", "Wed", "Thu", "Fri"],
  datasets: [{ label: "Signups", data: [12, 18, 15, 21, 17] }],
} satisfies ChartData;

<Chart
  title="Weekly signups"
  description="Signups peaked on Thursday."
  xAxisLabel="Day"
  yAxisLabel="Signups"
  data={weeklySignups}
/>

Compare series with a named legend

A legend appears automatically when a chart has more than one dataset. Use a specific text label for every series; color is only a supporting cue.

Qualified opportunities by source

Product-led opportunities increased in April.

Qualified opportunities by source (Opportunities)
MonthProduct-ledPartner-led
Jan2412
Feb3115
Mar2918
Apr3816
import { Chart, type ChartData } from "@smoothie-framework/whisk-react";

const acquisitionBySource = {
  type: "line",
  labels: ["Jan", "Feb", "Mar", "Apr"],
  datasets: [
    { label: "Product-led", data: [24, 31, 29, 38] },
    { label: "Partner-led", data: [12, 15, 18, 16] },
  ],
} satisfies ChartData;

<Chart
  title="Qualified opportunities by source"
  description="Product-led opportunities increased in April."
  xAxisLabel="Month"
  yAxisLabel="Opportunities"
  data={acquisitionBySource}
  showLegend
  legendInteraction="click"
/>

Show composition with stacked bars

Use stacked bars only when the series form an additive total for each category. stacked100 is for comparing shares, not absolute amounts. Both stacked variants reject negative values.

Qualified pipeline by region

  • Standard
  • Enterprise
Qualified pipeline by region (Opportunities)
RegionStandardEnterprise
North187
South129
West146
import { Chart, type ChartData } from "@smoothie-framework/whisk-react";

const planMix = {
  type: "bar",
  labels: ["North", "South", "West"],
  datasets: [
    { label: "Standard", data: [18, 12, 14] },
    { label: "Enterprise", data: [7, 9, 6] },
  ],
} satisfies ChartData;

<Chart
  title="Qualified pipeline by region"
  xAxisLabel="Region"
  yAxisLabel="Opportunities"
  data={planMix}
  barVariant="stacked"
/>

Use a pie chart for one positive whole

Pie accepts exactly one dataset with non-negative values and at least one positive value. Use it for a small set of parts of one whole, not a trend or a comparison across measures.

Team time by work type

Hours recorded this week.

  • Product work
  • Customer support
  • Operations
Team time by work type
LabelHours
Product work42
Customer support28
Operations30
import { Chart, type ChartData } from "@smoothie-framework/whisk-react";

const workByType = {
  type: "pie",
  labels: ["Product work", "Customer support", "Operations"],
  datasets: [{ label: "Hours", data: [42, 28, 30] }],
} satisfies ChartData;

<Chart
  title="Team time by work type"
  description="Hours recorded this week."
  data={workByType}
/>

Reduce visual label density without losing data

xAxisLabelMode changes only the labels drawn on a cartesian plot. The focusable plot targets and exact accessible table keep every category and value available.

Daily product events

Daily product events
LabelEvents
1 Oct8
2 Oct11
3 Oct7
4 Oct14
5 Oct13
6 Oct16
7 Oct12
import { Chart, type ChartData } from "@smoothie-framework/whisk-react";

const dailyEvents = {
  type: "line",
  labels: ["1 Oct", "2 Oct", "3 Oct", "4 Oct", "5 Oct", "6 Oct", "7 Oct"],
  datasets: [{ label: "Events", data: [8, 11, 7, 14, 13, 16, 12] }],
} satisfies ChartData;

<Chart
  title="Daily product events"
  data={dailyEvents}
  lineVariant="area"
  lineStyle="dashed"
  showPoints={false}
  xAxisLabelMode="endpoints"
/>

Props

Component props

PropTypeDefaultDescription
titlestringnoneRequired nonblank chart name. It labels the chart group and the exact-value table.
description | headingLevelstring | 1–6none | 3Add context for interpreting the chart and choose the semantic heading level without changing its visual size.
dataChartDatanoneRequired ordered data: bar and line accept one to four datasets; pie accepts exactly one. Every dataset has one finite number per label.
xAxisLabel | yAxisLabelstringnoneName the cartesian axes. The y-axis label is also included in the accessible table caption.
barVariantgrouped | stacked | stacked100groupedBar charts only. Stacked variants require non-negative values; stacked100 shows each category as a share.
lineVariant | lineStyle | showPointsline | area | solid | dashed | booleanline | solid | trueLine charts only. Choose an area treatment, dashed stroke, or hide persistent point markers.
xAxisLabelModeauto | all | endpointsautoCartesian charts only. Controls which category labels are visibly drawn; it never removes exact values from the accessible table.
showLegend | legendInteractionboolean | none | hover | clickautomatic | noneThe legend appears automatically for pie and multi-series charts. hover and click only highlight the rendered series; they do not filter, mutate, or emit data.
className | style | native div attributesnative div attributesnoneTarget the chart group directly. Chart does not accept children, custom marks, custom tooltips, or callbacks for data points.

Accessibility

Chart renders a labelled group, a visible heading, an SVG plot, focusable category or slice targets, and a visually hidden native table containing the exact source values. Hover and focus show the same tooltip; Escape dismisses an open tooltip. The legend pairs each color with a text label, and interactive legends are real buttons. Write a specific title, meaningful dataset labels, and axis labels where the measure is not already clear. Do not rely on color, the plot, or an automatic summary alone to communicate an important conclusion. Chart does not provide arrow-key navigation, activation, drill-down, or data-update announcements.

Content guidance

Name the measure and time frame in the title, and use a description to explain the takeaway or comparison. Keep dataset and category labels specific enough to stand alone in the legend, tooltip, and data table.