Skip to main content

Bar and line

A bar chart compares values across categories; a line chart shows a trend. The second line is dashed, so the two series differ by more than colour. Each canvas sits in an element with role="img" and an aria-label that says what the chart shows, and View as table swaps it for the same data as a real table, which screen reader and keyboard users can read.

Visitors per day

Revenue per month

  • 2026
  • 2025

Area and stacked bar

An area chart is a line with a soft fill, good for one quantity over time. A stacked bar splits each total into parts; with several series the colours are explained by a text legend, not only by the canvas.

Sessions this week

Orders per quarter by channel

  • Online
  • Retail
  • Partners

Doughnut

A doughnut shows parts of a whole. The total sits in the middle as text, and the legend lists every part with its value and share, so the numbers are never only in the picture. Use it for a handful of parts; for more, use a bar chart.

Sessions by source

Sparkline

A small line without axes beside a number, in a stat card. It only hints at the direction, so it is hidden from assistive technology (aria-hidden) and the change is written as text (“Up +12.4% vs last month”) with an arrow icon, never as colour alone. The colour follows the trend; variant changes it when a fall is good, and note adds a neutral line. It has no tooltip and takes no mouse events.

Revenue

$17,400

Up +12.4% vs last month

Orders

1,248

Up +7.9% vs last month

Conversion

2.8%

Down -0.6% vs last month

Costs

$6,210

Down -8.1% vs last month

Lower is better.

Churn

4.3%

Up +0.9% vs last month

Target: below 3%.

Sessions

38,902

Up +1.2% vs last month

Includes internal traffic.

Options reference

The charts are Chart.js drawn on a canvas; the page keeps the theme, the data and the table in one small Alpine component.

Part Value Description
Library chart.js@4.6.1 Loaded from the CDN before Alpine, as in the layouts. Use the UMD build: chart.umd.min.js.
chartCard(key, kind) Alpine component Draws DATA[key]. Kinds: bar, stacked, line, area, doughnut, spark. Put a <canvas x-ref="canvas"> inside.
DATA[key] { format, labels, series } format is number, currency or percent. A series is { name, data, dashed? }.
Size parent element The chart fills its parent (maintainAspectRatio: false), so give the parent a height such as h-64.
Colours THEME Hex values of the Starkit theme: the 700 shade on a light surface, the 400 shade on a dark one, with grid and text colours for each. Canvas cannot use Tailwind classes, so keep the values in one place.
Dark mode automatic A MutationObserver on the class of <html> redraws the chart when the theme changes, without a reload.
Accessibility role="img", aria-label, table Describe the chart in the label, repeat the numbers in the table (View as table) and in a text legend. Decorative sparklines are aria-hidden.
Motion prefers-reduced-motion Animation is turned off when the person asks for reduced motion.
Tooltips mouse only Chart.js tooltips need a pointer; the table is the keyboard and touch alternative.