Skip to content
OpenChart

Blog

How to choose, label and build charts for news, with the spec behind every figure.

  1. How to make a population pyramid in JavaScript

    A population pyramid draws a country's ages as back-to-back bars. This post builds Japan's from UN data, then animates it from 1950 to 2100.

  2. How to make an animated bubble chart in JavaScript

    An animated bubble chart plays a scatter plot one year at a time. This post builds the Gapminder chart from World Bank data, with trails, labels and controls.

  3. How to make an animated choropleth map

    An animated choropleth recolors each state as the weeks play. This post builds one from 2020 unemployment claims, on a states map and on a tile map.

  4. When to use an animated chart instead of small multiples

    Animation shows movement over many years; small multiples let readers compare them. World Bank data drawn three ways shows what each view keeps and loses.

  5. How to make a bar chart race in JavaScript

    A bar chart race plays a ranking one period at a time. This post builds one from World Bank GDP data, swaps it to lines and a table, and exports a GIF.

  6. When to use a bar chart race

    A bar chart race shows the order in which entries overtook each other. Census data shows what it hides, and when a bump chart or line chart works better.

  7. How to make a slope chart in JavaScript

    A slope chart compares two moments with one line per item. This post uses fatal accidents at 11 airlines and covers how to choose the two endpoints.

  8. What to use instead of a dual-axis chart

    Two y axes let the author choose how far apart two trends look. This post draws the same road-death data as separate panels and as one indexed chart.

  9. Responsive charts on mobile

    On a phone, OpenChart thins the axis ticks on its own. The title length and which callout stays are still your call.

  10. How to chart a temperature anomaly

    How to chart each year's temperature against a baseline, and when to use bars or a line.

  11. Stacked bar chart vs grouped bar chart

    Stacked bars show the total, and grouped bars let you compare the parts. This post also covers how to order the segments of a stack.

  12. Direct labels vs legends on line charts

    Labeling each line at its end saves readers a trip to the legend. Some charts still need the legend.

  13. Export a chart as PNG, SVG or GIF from JavaScript

    Save an OpenChart chart as SVG, PNG or GIF with chart.export, and see how large each file gets for one real chart.

  14. How to choose a histogram bin size

    The same 51 state incomes drawn with three bin widths look like three different distributions. Two rules of thumb help you pick a width.

  15. Accessible charts for the web

    OpenChart gives every chart a text label and keyboard navigation by default. You still write the alt text, and this post shows how to test it.

  16. Choropleth vs tile map for US state data

    A geographic map gives Alaska and Texas far more room than Rhode Island and DC. A tile map gives each state one square. The same unemployment data, both ways.

  17. How to build a KPI dashboard with sparklines

    A KPI tile is a number, a comparison and a small line. This post builds a row of them and covers what to label once the sparkline has no axes.

  18. How to use small multiples

    When a line chart has too many series, give each one its own panel. Then decide whether the panels share a y scale.

  19. When to use a table instead of a chart

    Tables win when readers need exact values or mixed units. Inline bars and cell shading add a visual scan without removing the numbers.

  20. How to annotate a line chart

    Every annotation should answer a question the reader would otherwise have. Three types cover most line charts, and three per chart is a good limit.

  21. How to make a beeswarm plot

    A beeswarm plot draws one dot per data point, so you can see which states fell and by how much. This post builds one and then splits it into groups.

  22. Server-side chart rendering with static SVG

    renderStaticSVG turns a chart spec into an SVG string in Node, with no browser. The output works with JavaScript off but has no tooltips or animation.

  23. How to read and build a Sankey diagram

    A Sankey diagram shows where a total goes. This post reads one of US energy flows, then builds it from a list of flows.

  24. Lollipop chart vs bar chart

    Lollipop charts suit long ranked lists better than bars do, but the stems still have to start at zero.

  25. Declarative chart spec vs D3

    One line chart built twice, as a 45-line JSON spec and in 97 lines of D3, to show what each approach costs and gives you.

  26. Pie chart vs bar chart vs waffle chart

    A pie works for one dominant share, bars for close values, and a waffle for one percentage you want counted. Examples use US debt and federal spending.

  27. When bar charts must start at zero

    A bar's length carries its value, so cutting the axis distorts the comparison. A line's position carries it, so a line axis can start closer to the data.

  28. How to chart a range of values

    An average hides how far values spread. A range plot shows each month's low and high instead, and the post says when error bars or a histogram fit better.

  29. How to make a heatmap in JavaScript

    A heatmap colors each cell of a grid by a number. This post builds two, one with a sequential color scale and one with a diverging scale.

  30. When to use a log scale on a scatter plot

    When values span orders of magnitude, a linear axis crowds most points into one corner. A log scale spreads them out, but readers misread it more easily.

  31. Colorblind-safe chart palettes for light and dark mode

    Charts that rely on red against green fail for readers with color vision deficiency. This post covers palettes that work in light and dark mode.