024 / RECHARTS / BAR & COLUMN
Bullet Bars
Compact actual-versus-target bars for operational scorecards, with per-category target markers, truthful delta semantics, and responsive row-based inspection.
- SPEC
- #024
- ENGINE
- Recharts
- FAMILY
- Bar & Column
- RENDERER
- svg
- STATUS
- preview
Installation
Checking public registry…
View local registry JSONCopied as source into your project (requires recharts).
Overview
Bullet Bars is Plotcn's specialized operational scorecard component designed specifically for comparing an actual quantitative measure against an explicit per-category target. It answers the fundamental analytical question:
“Where does the current measure sit relative to its explicit target?”
Secondary analytical questions answered by this component include:
- “How far is the measure from the target?”
- “Has the measure reached, exceeded, or fallen short of the configured target?”
- “Where does the current value sit within optional caller-defined operating ranges?”
import { BulletBars } from "@/components/charts/recharts/bar-bullet"const serviceSla = [ { service: "Auth API", actual: 99.95, target: 99.90 }, { service: "Search API", actual: 99.82, target: 99.90 }, { service: "Checkout API", actual: 99.91, target: 99.95 }, { service: "Profiles API", actual: 99.97, target: 99.90 }, { service: "Notifications API", actual: 99.88, target: 99.90 },]export function ServiceSlaChart() { return ( <BulletBars data={serviceSla} categoryKey="service" series={{ valueKey: "actual", targetKey: "target", label: "Availability", valueFormatter: (v) => `${v.toFixed(2)}%`, }} showGrid /> )}Governing Principle
Bullet Bars compares an actual quantitative measure against an explicit target without inventing performance judgment. The measure is data, the target is data, optional qualitative ranges are caller-supplied context, and Plotcn must never silently infer what counts as good, bad, safe, risky, complete, or successful.
This principle governs:
- Structural distinction: The actual measure uses bar length; the target uses a thin vertical rule marker.
- Shared scale: Actual and target share exactly one quantitative scale so direct visual comparison is mathematically truthful.
- Neutral delta:
delta = actual - target. Language is strictly positional ("Actual above target", "Actual below target", "Actual on target"), never judgmental ("Passed", "Failed", "Good", "Bad"). - Zero-target validity: Target of 0 is mathematically valid without division-by-zero errors.
- Missing-data resilience: A missing actual renders the target marker; a missing target renders the actual bar; no fake zeros or guesses are manufactured.
Bar-Family Specialization
Bullet Bars is a dedicated operational scorecard primitive. It is fundamentally distinct from other Plotcn bar components:
| Component | Analytical Question | Visual Encoding | Reference Geometry |
|---|---|---|---|
| Signal Bars | “How large is each category?” | Single or grouped bars from 0 baseline | Shared 0 baseline |
| Rank Bars | “Which categories lead or lag?” | Ranked horizontal bars | Order-based ranking |
| Group Compare Bars | “How do peer measures compare side-by-side?” | Peer bars side-by-side | Shared 0 baseline |
| Stack Ledger Bars | “What is the additive categorical total?” | Additive stacked segments | Cumulative composition |
| Percent Stack Bars | “How is the whole shared across contributors?” | 100% normalized segments | 0% to 100% envelope |
| Diverging Bars | “How does each category deviate from reference?” | Signed deviation bars extending left/right | Single common baseline |
| Bullet Bars | “Where does the measure sit relative to its target?” | Filled actual bar + per-category target marker | Independent target rule per category |
Bullet Anatomy
A canonical Bullet Bar row combines five coordinated structural elements into an ultra-compact operational scorecard layout:
- Category identifier: Left-aligned discrete category label.
- Actual measure bar: Solid quantitative bar extending from 0 to the observed value.
- Target marker: Crisp vertical rule marker positioned at the target value on the exact same scale.
- Shared quantitative scale: Uniform numeric scale governing all rows.
- Optional qualitative ranges: Subdued background bands providing operational context without visual dominance.
Bullet Chart Anatomy: Category, Measure, Target Marker & Context Ranges
Anatomy of a Bullet Bar scorecard row showing discrete category label on the left, optional background qualitative bands, solid actual measure bar, prominent target marker rule, and shared quantitative axis scale.
Actual vs Target: Three Positional States
In Bullet Bars, the actual value can sit in three spatial relationships relative to the target:
- Actual below target: Bar end falls short of the target line (
delta < 0). - Actual on target: Bar end coincides exactly with the target line (
delta = 0). The target marker remains visible layered above the bar end. - Actual above target: Bar end extends past the target line (
delta > 0). The bar continues through the target without artificial clipping.
Positional Truth: Below Target, Equal Target, Above Target
Three scorecard rows illustrating the three factual spatial states: actual value falling short of the target line, actual value matching the target line exactly with visible marker, and actual value extending past the target line without artificial clipping.
Per-Category Target Marker Architecture
Unlike a global reference line that crosses the entire chart at a single static value, target markers in Bullet Bars are per-category. Each row positions its target marker at its own explicit target coordinate:
Per-Category Target Markers vs Global Reference Lines
Comparison contrasting a global reference line which spans every row at an identical value versus row-local target markers which position independently at each record's specific target.
Shared Quantitative Scale
All rows in a BulletBars chart share a single quantitative numeric scale. This guarantees that equal actual values produce identical bar lengths across different rows, even when their target markers sit at different coordinates:
Shared Quantitative Scale: Equal Measures Produce Equal Bar Lengths
Target Delta Derivation
Plotcn computes target delta as raw arithmetic:
Delta is computed only when both actual and target values are valid finite numbers. Delta is never interpreted as performance quality:
Target Delta = Actual − Target: Pure Arithmetic, Not Moral Judgment
Calculation flow demonstrating delta derived as actual minus target with neutral interpretation regardless of sign.
Missing Actual vs Missing Target Resilience
Real-world operational scorecards often encounter missing or delayed metrics:
- Actual missing (
nullorundefined): The actual bar is suppressed (no fake zero bar). The target marker remains visible at its configured coordinate. - Target missing (
nullorundefined): The actual bar renders normally. No target marker is fabricated. - Both missing: The category row is preserved with empty track. Tooltip displays "Incomplete".
Missing Actual vs Missing Target: Truthful Representation Without Guesswork
Two-panel diagram showing that when actual is missing, the target marker still renders clearly, and when target is missing, the actual bar renders without fabricated target markers.
Zero Target Safety
A target value of zero (target = 0) is valid in error-budget, defect-rate, and incident-tracking metrics. Plotcn handles zero targets seamlessly because it avoids percentage-to-target division math:
Zero Target Safety: Target = 0 Without Division by Zero
Demonstration showing that target equals zero places the target rule directly at the baseline and computes delta without division by zero errors.
Full Row Hit Testing
To ensure seamless scrubbing on both fine desktop pointers and coarse mobile touchscreens, Bullet Bars turns the entire row band into an interactive hit region:
Full Row Hit Testing: Effortless Scrubbing Even for Zero or Missing Actuals
Illustration showing that the interactive hit target encompasses the entire row band (44px height) rather than requiring exact hover over thin bars or target rules.
Responsive Row Recomposition
Bullet Bars adapts smoothly across device viewports. On spacious desktop displays, category labels and outward value callouts sit inline. On compact mobile screens (320px–440px), the component preserves full actual and target markers while tightening row padding:
Desktop vs Compact Layout: Target Markers Never Disappear
Comparison showing spacious desktop scorecard layout with full category labels and inline callouts versus compact mobile layout which adjusts padding while strictly preserving the actual bar and target marker.
Rendering Architecture Pipeline
From caller data to accessible SVG mark, Bullet Bars enforces strict finite math validation, monotonic range boundaries, shared scale derivation, and offscreen accessibility alternatives:
Bullet Bars Architecture: From Caller Records to Accessible SVG Mark
End-to-end rendering pipeline showing consumer records passing through finite number validation, arithmetic delta calculation, shared quantitative domain derivation, Recharts Cartesian layout, layered SVG shapes, and accessibility dispatch.
Installation
npx shadcn@latest add @plotcn/bar-bulletProperties Reference
| Property | Type | Default | Description |
|---|---|---|---|
data | readonly TData[] | [] | Array of categorical data records. Order is caller-preserved. |
categoryKey | keyof TData & string | — | Record key representing the discrete category label. |
series | BulletBarSeries<TData> | — | Definition containing valueKey, targetKey, label, and optional formatters. |
ranges | readonly BulletRange[] | undefined | Optional caller-defined qualitative background context ranges. |
height | number | string | auto | Container height in pixels. If omitted, derives from row count. |
rowHeight | number | 48 | Target height per scorecard row in pixels. |
domain | [number, number] | "auto" | "auto" | Quantitative domain in data space. |
valueColor | string | "var(--chart-1)" | Fill color for the actual measure bar. |
targetColor | string | "var(--chart-foreground)" | Stroke color for the per-category target marker rule. |
selectionColor | string | "var(--chart-selection)" | Accent stroke color for the active/focused row. |
showGrid | boolean | true | Whether to render subtle Cartesian gridlines. |
showLegend | boolean | false | Whether to display the structural legend. |
valueLabel | "none" | "value" | "auto" | "none" | Outward inline numeric label rendering policy. |
motion | boolean | { duration?: number } | true | Animation toggle honoring reduced-motion preferences. |
Props Reference & Interactive Prop Explorer
Inspect every component property, customize semantic color roles live with instant visual feedback, and copy production-ready code with active prop configurations.
Colors & Appearance Configuration
Customize primary, reference, or annotation series colors. Defaults derive from Plotcn theme tokens.
<BulletBars
data={data}
categoryKey="service"
series={{
valueKey: "actual",
targetKey: "target",
label: "Availability",
}}
/>Optional monotonic qualitative background context bands.
ranges={undefined}Default: undefinedWhether to render subtle Cartesian gridlines.
showGrid={true}Default: trueWhether to display the structural legend.
showLegend={false}Default: falsePolicy for rendering inline numeric labels at outward bar ends.
valueLabel="none"Default: "none"| Property | Type | Default | Required | Description |
|---|---|---|---|---|
dataReq | readonly TData[] | [] | Yes | Array of categorical data records. Order is strictly preserved. |
categoryKeyReq | keyof TData & string | — | Yes | Key on data records representing the discrete category label. |
seriesReq | BulletBarSeries<TData> | — | Yes | Series definition specifying valueKey, targetKey, label, and optional formatters. |
rangesOpt | readonly BulletRange[] | undefined | No | Optional monotonic qualitative background context bands. |
heightOpt | number | string | auto | No | Total container height. Derived automatically from row count if omitted. |
rowHeightOpt | number | 48 | No | Target height in pixels for each scorecard row. |
domainOpt | [number, number] | "auto" | "auto" | No | Quantitative domain. 'auto' encompasses 0, all actuals, targets, and range limits. |
valueColorOpt | string | "var(--chart-1)" | No | Fill color for the actual measure bar. |
targetColorOpt | string | "var(--chart-foreground)" | No | Stroke color for the per-category target marker rule. |
string | "var(--chart-selection)" | No | Accent stroke color for the active scorecard row. | |
showGridOpt | boolean | true | No | Whether to render subtle Cartesian gridlines. |
showLegendOpt | boolean | false | No | Whether to display the structural legend. |
valueLabelOpt | "none" | "value" | "auto" | "none" | No | Policy for rendering inline numeric labels at outward bar ends. |
motionOpt | boolean | { duration?: number } | true | No | Animation toggle honoring reduced-motion preferences. |
Component Variants & Edge States
Production cookbooks showcasing configuration variants alongside verified handling of loading, empty data, and network error states.
Service Availability vs SLO
Standard operational scorecard comparing service availability against explicit SLA targets in percentage space.
Regional Revenue vs Target
Comparing regional financial performance against varied regional sales targets on a shared currency scale.
Zero Target Defect Rate
Validating that target = 0 renders truthfully at the baseline without division errors.
Skeletons indicate runtime fetch or pending data queries.
Handles empty collections ([]) gracefully without crashing.
Graceful failure banner when data source or script fails.
Container-Driven Breakpoints
Bullet Bars adapts fluidly across device viewports. The horizontal orientation ensures category labels remain readable while target markers and actual bars maintain direct scale alignment down to 320px.
Full categorical tick labels, outward numeric value callouts, and spacious analytical tooltips disclosing actual, target, and delta.
Compact category labels, preserved target marker rules, and responsive tooltip clamping within container bounds.
Strict touch-action pan-y preservation, tightened row margins, and full 44px touch hit targets across each scorecard row.
Accessibility & Navigation Standards
Semantic figure region with single tab stop, vertical arrow-key navigation (ArrowUp/ArrowDown) through scorecard rows, Home/End traversal, polite ARIA live announcements, and an offscreen structured HTML table disclosing actuals, targets, and deltas.
Container mounts as region with explicit assistive label.
Actual measure is encoded by bar length; target reference is encoded by a vertical rule marker. The distinct geometry guarantees complete non-color accessibility even in pure Monochrome.
Embeds visually hidden summary (.sr-only) declaring: “Announces category name, observed actual value, reference target, and arithmetic delta. Factual accessibility summary details counts above, below, and on target.”
All initial entrance animations are bypassed immediately when prefers-reduced-motion is detected.
| Key | Action |
|---|---|
| ArrowDown | Move focus to the next scorecard row |
| ArrowUp | Move focus to the previous scorecard row |
| Home | Jump focus to the first category |
| End | Jump focus to the last category |
| Escape | Clear active row inspection |
Internal Architecture & File Dependencies
Source-first ownership model. Inspect the exact component call tree, dependencies, and full implementation below.
Provides responsive container sizing and design tokens