Home / Comparison Charts / Bullet Chart

Bullet Chart in HTML, CSS and JavaScript

A bullet chart shows a result, a target and how good the result is, all in one row. This free template draws one with plain SVG and vanilla JavaScript, no chart library. The example shows solar panel installs against target for six regions.

Open live demoDownload HTML fileView code on GitHub
Bullet Chart made with HTML and JavaScript showing solar panel installs against target for six regions

What is a bullet chart?

A bullet chart shows a result, a target and how good the result is, all in one row. A dark bar shows the actual value, a short line shows the target, and gray bands behind show ranges like poor, fair and good.

It was designed by Stephen Few as a small, honest replacement for dashboard gauges. You can stack many bullet charts in the space of one gauge, so a whole sales team fits on a single screen.

At a glance

Best for
Goals, targets and KPIs on dashboards
Data you need
Actual, target and 2 or 3 range limits per row
Skip it when
Showing trends. Pair it with a line chart.
Made with
HTML, CSS and vanilla JavaScript. No library.

When to use a bullet chart

  • Sales against quota by rep or region
  • Budget spent against budget planned
  • Website goals like sign ups against target
  • Project progress against the plan

When to pick another chart

What you get in this template

How the code works

Here is a short version of the idea behind this bullet chart. The full file adds the axis, labels, tooltips, sorting and resizing on top of it.

const regions = [['South', 188, 170, [120, 150, 200]], ['East', 97, 140, [95, 125, 165]]];
const x = v => 90 + v / 200 * 450;
const bands = ['#cbc3a8', '#dcd6c2', '#eeeadf'];

regions.forEach(([name, actual, target, ranges], row) => {
  const y = 20 + row * 60;
  [...ranges].reverse().forEach((r, i) => drawRect(90, y, x(r) - 90, 40, bands[2 - i]));
  drawRect(90, y + 13, x(actual) - 90, 14, '#22211b');     // actual
  drawLine(x(target), y + 5, x(target), y + 35, '#e85d04', 4); // target
});

The example uses four tiny helpers that create SVG shapes. Put them above the code and it runs as is.

const svg = document.querySelector('svg');
function make(tag, attrs) {
  const n = document.createElementNS('http://www.w3.org/2000/svg', tag);
  for (const k in attrs) n.setAttribute(k, attrs[k]);
  svg.appendChild(n);
  return n;
}
function drawRect(x, y, width, height, fill) { return make('rect', { x, y, width, height, fill }); }
function drawCircle(cx, cy, r, fill) { return make('circle', { cx, cy, r, fill }); }
function drawLine(x1, y1, x2, y2, stroke, width, dash) {
  return make('line', { x1, y1, x2, y2, stroke, 'stroke-width': width || 1, 'stroke-dasharray': dash || 'none' });
}
function drawText(x, y, str, anchor) {
  const t = make('text', { x, y, 'text-anchor': anchor || 'start' });
  t.textContent = str;
  return t;
}

How to add it to your website

  1. Download the file. Click Download HTML file above. You get one file called bullet-chart.html with everything inside.
  2. Change the data. Open the file in any code editor and find the DATA list near the bottom. Replace the names and numbers with your own.
  3. Change the colors and text. Colors are at the top of the style tag. The title, subtitle and main point are plain HTML near the top of the body.
  4. Put it online. Upload the file to any host, such as GitHub Pages, Netlify or your own server, or paste it into your site. There is no build step.

Questions people ask

What is a bullet chart?

A bullet chart is a bar that shows an actual value against a target, with shaded bands behind it for ranges like poor, fair and good. It is used on dashboards to track goals.

Who invented the bullet chart?

Stephen Few, a data visualization expert, designed it in 2005 as a compact replacement for gauges and meters on dashboards.

Why use a bullet chart instead of a gauge?

A bullet chart shows the same information in a fraction of the space and is easier to compare. Ten bullet charts fit where one gauge would.

What do the gray bands mean in a bullet chart?

They show qualitative ranges. Here the darkest band is poor, the middle is fair and the lightest is good. You set the limits for each row.

More comparison charts