Bullet
A bullet chart, Stephen Few’s compact alternative to a dashboard gauge: a single measure bar against qualitative range bands and a target tick, for tracking a KPI against a goal without a speedometer’s wasted space.
Usage
from dataviz import bullet
from dataviz import save
from dataviz import Theme
def main() raises:
# Every row shares one unit: percent of orders shipped on time.
# Qualitative ranges mark needs-attention, acceptable, and strong.
var regions: List[String] = [
"Northeast", "Midwest", "South", "Mountain", "Pacific",
]
var measures: List[Int] = [94, 87, 91, 82, 96]
var targets: List[Int] = [95, 92, 93, 90, 95]
var ranges: List[List[Float64]] = [
[80.0, 90.0, 100.0],
[80.0, 90.0, 100.0],
[80.0, 90.0, 100.0],
[80.0, 90.0, 100.0],
[80.0, 90.0, 100.0],
]
var c = bullet(
regions,
measures,
targets,
ranges,
title="Illustrative On-Time Fulfillment by Region",
x_title="Orders shipped on time (%)",
)
save(c, "docs/src/examples/out_bullet.svg")See Data shapes for shared input conventions.
Args:
categories: One row per entry, in the given order.measures: Each category’s actual value, drawn as the narrow measure bar.targets: Each category’s goal value, drawn as a tick mark across the full band width.ranges: Each category’s own list of ascending qualitative- range thresholds (poor/satisfactory/good, …), drawn as shaded background bands from lightest to darkest.measure_width_fraction: The measure bar’s thickness as a fraction of the band width; defaults to0.35.horizontal: Whether the categories run down the page and the measures rightward; defaults toFalse. Usually the form you want: the rows read as progress bars against their targets, and KPI names are long.theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – seeTheme’s docstring.width: Pixel width of the returnedPlot(.size()).height: Pixel height of the returnedPlot(.size()).title: The chart’s title, shown above the plot.subtitle: A secondary line shown under the title.x_title: The x-axis caption.y_title: The y-axis caption.
Related
Related charts: Waterfall · Funnel
Relevant API: bullet