A bullet chart displays a single quantitative measure (the actual value) against qualitative range bands (e.g. poor / satisfactory / good) and an optional target marker. It was designed by Stephen Few as a compact, information-dense alternative to gauge charts.

bullet_chart(
  value,
  ranges,
  target = NULL,
  rangeColors = NULL,
  title = "",
  subtitle = "",
  min = 0,
  valueColor = "#1a1a2e",
  targetColor = "#e63946",
  tickCount = 5,
  fontSize = 12,
  font = "Verdana, Geneva, Tahoma, sans-serif",
  bgcol = "white",
  width = NULL,
  height = NULL
)

Arguments

value

Numeric. The actual value to display (the main bar).

ranges

Numeric vector of upper bounds for each qualitative band, in ascending order (e.g. c(40, 70, 100)). The lower bound of the first band is min.

target

Optional numeric. The target / goal value shown as a short vertical marker. Defaults to NULL (no marker drawn).

rangeColors

Character vector of colors for each band, in the same order as ranges. Defaults to a sequence of grays from darker (low range) to lighter (high range).

title

Character. Label displayed to the left of the chart. Defaults to "".

subtitle

Character. Smaller label displayed below title. Defaults to "".

min

Numeric. The minimum value of the scale. Defaults to 0.

valueColor

The color of the actual-value bar. Defaults to "#1a1a2e".

targetColor

The color of the target marker. Defaults to "#e63946".

tickCount

Number of axis ticks. Defaults to 5.

fontSize

Base font size in pixels. Defaults to 12.

font

The font family used for all text. Defaults to "Verdana, Geneva, Tahoma, sans-serif".

bgcol

The background color of the SVG. Defaults to "white".

width

Optional. The width of the SVG output.

height

Optional. The height of the SVG output.

Value

An SVG bullet chart.

Examples

# Sales revenue vs target
bullet_chart(
  value  = 270,
  target = 300,
  ranges = c(150, 225, 350),
  title  = "Revenue",
  subtitle = "USD thousands"
)
# Customer satisfaction score bullet_chart( value = 7.4, target = 8.0, ranges = c(4, 7, 10), title = "Satisfaction", subtitle = "out of 10", valueColor = "steelblue" )
# Server response time (lower is better — ranges go poor → good left to right) bullet_chart( value = 320, target = 250, ranges = c(200, 500, 1000), rangeColors = c("#f5f5f5", "#e0e0e0", "#c0c0c0"), title = "Response", subtitle = "ms", min = 0 )