Skip to content

Chart

Line, area, bar, pie, donut and sparkline charts, drawn from a plain HTML table, or from data in JavaScript, with no chart library. The table stays as the chart’s data view, so every number is readable without the chart.

CSS
css/components/chart.css
JS
js/components/chart.js
Docs
docs/charts.md

01 — Chart types

Line chart

Change over time, for up to five series. Hover or tap a point for its card; focus the chart and use the arrow keys.

Monthly rides By bike type, January to September 2026
MonthClassicElectricCargo
Jan120,40061,2003,100
Feb118,20063,9003,300
Mar141,90078,4004,200
Apr152,30092,1005,600
May168,700108,6006,900
Jun171,200117,3007,400
Jul176,500124,9007,900
Aug169,800121,4007,600
Sep158,300116,8007,100

Stacked area chart

data-type="area" data-stacked: how parts add up to a total over time.

Rides through the day Average weekday, stacked by ticket type
TimeMembersDay passesSingle rides
6 am4204060
8 am1,38090180
10 am610210160
12 pm720380240
2 pm680420230
4 pm1,120360260
6 pm1,450290310
8 pm640210220
10 pm26080120

Bar chart

Comparing amounts across categories.

Stations opened Per year
YearStations
20196
20209
20214
202212
202315
202411
202518
202621

Grouped bar chart

Two or more series side by side in each category.

Average daily rides By day of the week, 2025 and 2026
Day20252026
Mon7,8208,640
Tue8,1108,920
Wed8,2409,180
Thu8,0508,970
Fri7,6308,410
Sat6,1207,050
Sun5,4806,230

Pie chart

Parts of one whole, up to six slices.

Why people ride Rider survey, 2026
PurposeShare of trips
Commuting46%
Leisure24%
Errands18%
Exercise12%

Donut chart

A pie with the total in the middle. Set the center with data-center-label.

The fleet By bike type, September 2026
Bike typeBikes
Classic620
Electric340
Cargo40

Sparkline

A tiny trend line for inside a stat. It takes its data from attributes and says the trend in its aria-label.

Members
12.4K

02 — Options

Attributes

OptionValues
data-typeline, area, bar, pie, donut, sparkline
data-stackedStack area or bar series.
data-prefix, data-suffixFor axis ticks: $, %, h.
data-heightPlot height in px (default 260).
data-center-label, data-center-valueThe donut’s center (default: Total and the sum).

03 — From data

Live data

For apps that hold the numbers themselves, such as React state or a live feed. Jewel.chart.render() writes the table and draws the chart; update() redraws it in place. The table is still there behind “Show data”, so the keyboard and screen reader view keep working. Press the button to send new numbers.

JS
const chart = Jewel.chart.render(document.querySelector('#pods'), {
  type: 'donut',
  title: 'Pods by state',
  categoryLabel: 'State',
  labels: ['Running', 'Pending', 'Failed'],
  series: [{ name: 'Pods', values: [12, 5, 1] }],
});

// Later, when the data changes:
chart.update({ series: [{ values: [14, 3, 1] }] });

In React

Render once in an effect, call update() when the data changes, and let Jewel own the element’s contents.

JSX
function PodsChart({ counts }) {
  const ref = useRef(null);
  const chart = useRef(null);
  useEffect(() => {
    chart.current = Jewel.chart.render(ref.current, {
      type: 'bar', categoryLabel: 'State',
      labels: ['Running', 'Pending', 'Failed'],
      series: [{ name: 'Pods', values: counts }],
    });
  }, []);
  useEffect(() => { chart.current?.update({ series: [{ values: counts }] }); }, [counts]);
  return <div ref={ref} />;
}

Data shape

FieldWhat it is
typeline, area, bar, pie, donut or sparkline. Fixed once drawn.
labelsThe categories: x axis points, bars or slices.
series[{ name, values }], one per line or bar group. Values are numbers, or null for a gap.
title, subtitleThe caption. Optional.
categoryLabelThe first column’s header in the table view.
stacked, prefix, suffix, heightThe same options as the data-* attributes.

update() merges, so leave out anything that hasn’t changed. Jewel.chart.update(figure, data) works on any chart, including ones written as an HTML table.

04 — Usage

Use it for

  • The first column for categories; each further column is a series.
  • Cells written as they should read (“42%”, “120,400”). The hover card shows your text.
  • A title on every chart that says what it shows.

Avoid

  • More than five series. The sixth turns gray; fold extras into Other or split the chart.
  • Series colors on text.
  • Pie charts with more than six slices.

05 — Accessibility

Notes

  • Every chart keeps its table behind a “Show data” link, and the table is all that shows without a script.
  • Charts can be tabbed to; arrows step through points and a live region reads each one.
  • The palette is checked for color-blind contrast, and lines are labeled at their ends where they don’t collide.