What is it?

Tablechart makes a chart from a table in each figure (that has data-chart) on your page, while the table itself gets hidden. Assistive devices can keep reading the table instead of the chart.

A chart appears when it scrolls into view, but you can change the threshold so that it is always visible.

Apples picked
thousands
Spring 58
Summer 72
Autumn 70

See below how it is just a table in a figure:

HTML
<figure data-chart="column">
	<figcaption><b>Apples picked</b><br><span>thousands</span></figcaption>
	<table>
		<tbody>
			<tr><th>Spring</th><td>58</td></tr>
			<tr><th>Summer</th><td>72</td></tr>
			<tr><th>Autumn</th><td>70</td></tr>
		</tbody>
	</table>
</figure>

What makes it different

  • The data is a table. You write a table in your HTML, or in Markdown, or in a JSON file. You do not write JavaScript for each chart.
  • The table stays on the page. Screen readers, search engines and translation scripts read it. If JavaScript does not run, the table is shown instead of the chart (if written with a table, not generated from JSON).
  • The text is real and styleable text. Numbers, names and titles are HTML. They use the font of your page, stay sharp when the page is zoomed or scaled, and can be translated. No more Times New Roman in your charts.
  • Styled with CSS. A chart uses the text colour of the page. Colours, sizes and light and dark mode are CSS variables.
  • Annotations follow the data. A bracket or a trend arrow is placed by the numbers. If you change a number, the annotation moves with it.
  • Small. About 32 kB of JavaScript and CSS together, gzipped.
  • The result is also small. If Tablechart is used in a document that is converted to PDF, then the chart is still just vectors and text, not a bitmap image. Small and sharp at any zoom level.

Tablechart has no axes, gridlines or zooming. Every value is shown as a number on its bar or point. If a number does not fit, it is in the tooltip when you point at its row. If you need axes or zooming, for example for a dashboard, use a ‘bigger’ chart library.

Compared to Chart.js and D3

Tablechart Chart.js D3
Data A table, Markdown or JSON JavaScript JavaScript
Drawn with SVG, and HTML for the text Canvas SVG, usually
Styling CSS variables JavaScript options CSS or JavaScript
Chart types Column, bar, line, area, waterfall, donut, and scatter as an additional type Many Anything you build
Size, gzipped About 32 kB, with the CSS About 70 kB About 90 kB for the full bundle

A canvas has a fixed number of pixels, so a canvas chart becomes blurry when a page is zoomed or scaled up with CSS. SVG and HTML text stay sharp.

D3 is a toolkit for making charts, not a chart library. A bar chart in D3 is a few dozen lines of JavaScript. In Tablechart, it is a table and a data-chart attribute.

Next

See How it works, or Get started to add it to your page.


Support this project

Tablechart is free. If it saved you time, a coffee goes a long way.

Support my work on Ko-fi