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.
Made with OpenChart. How to build this bar chart
Comparing twelve major economies across population, income per person and life expectancy breaks a single chart. Population runs into billions, income is measured in purchasing-power dollars (adjusted for local price differences) and life expectancy spans roughly fifteen years. Anyone opening a multi-variable chart to check one country’s figures ends up decoding bubble sizes and color ramps or hunting through hover tooltips.
Made with OpenChart. How to build this bar chart
A horizontal bar chart handles one metric cleanly. Ranking these economies by income puts the United States at $75,489, nearly eight times India’s $9,818, and makes the gap between wealthy and middle-income nations clear at a glance. Population and longevity disappear completely unless you draw two more charts.
When to use a table
Use a table when readers arrive to look up exact values for specific rows. Reading a bar chart means tracing a bar end down to an axis tick and estimating between gridlines. Data labels fix that on a single metric, yet they crowd the plot as soon as each row carries three or four measurements. Printed digits let a reader pull Canada’s $58,321 income or 82.2-year life expectancy straight off the row.
Mixed units across variables also favor a table. Population, purchasing-power income and years of life share no common scale, and forcing them onto dual axes produces crossings that shift whenever someone rescales a side. Separate columns keep every unit plain under its own header.
A table lets each reader pick the ranking that answers their question. A bar chart locks every visitor into income order, forcing anyone curious about population size to scan up and down the labels. Clickable headers reorder the rows on demand, moving India and China to the top by population or placing Japan first by life expectancy.
Bars and shading inside a table
Right-aligning numeric columns with equal-width tabular numerals is the first visual cue a table borrows from charts. Lining up digits flush right puts commas and decimal points in one vertical track, so wider numbers stand out as larger values while country names stay left-aligned. Shortening billion-scale populations into compact labels like 1.4B keeps the column scannable when nobody needs nine trailing digits.
Inline bars bring proportional length comparison directly into a numeric column. Each cell draws a horizontal bar anchored at zero and scaled to the column’s maximum alongside its exact dollar value. Scanning down the income column exposes the sharp drop between the high-income economies and China, Mexico and Brazil while keeping every figure intact.
Subtle cell shading adds a second visual channel without competing with bar length. Shading life expectancy on a light sequential green ramp makes Japan’s 83.6 years and the lower longevity in India and Indonesia stand out while rows stay ordered by income. Keeping each column to a single visual cue keeps color and bar length easy to read separately.
Twelve large economies: population, income and life expectancy. This chart is drawn in the browser.
Made with OpenChart. How to build this data table
Tables still give up overall shape when a dataset grows large or continuous. A scatter plot shows the curved link between income and longevity across dozens of countries faster than reading two columns side by side, and a line chart reveals seasonal turns that rows of monthly numbers bury. Past twenty or so rows, pair a table with search or paging so lookup stays fast.
The spec
Code under the table opens its JSON spec, built from the same twelve rows as the bar chart. Setting "type": "table" replaces mark and encoding channels with a columns array mapping each field key to a header label. The format option accepts "compact" to abbreviate billion-scale populations into labels like 1.4B, alongside d3-format strings such as "$,.0f" for whole dollars and ".1f" for one decimal place.
Every visual cue and interactive control sits on its column or at the top level of the spec. Setting align: "right" keeps numbers flush along their final digit, bar: { color: "#0e7490" } draws proportional bars in the income column, and heatmap: { palette: "green" } shades life expectancy cells. Setting sortable: true enables header clicks, sort picks the starting order, density: "condensed" keeps all twelve rows in view, and search: true adds the filter box. On phones, mobileLayout: "scroll" keeps the grid rather than cards.
To add paging, total rows or sparkline cells to your own tables, start with the data table guide.