Command Palette

Search for a command to run...

Docs
Bullet Chart

Bullet Chart

A versatile bullet chart component for comparing actual values against targets with qualitative ranges. Includes horizontal, vertical, compact, interactive, legend, and custom color variants.

Installation

Usage

import {
  BulletChart,
  BulletLegendChart,
  BulletVerticalChart,
  BulletCompactChart,
  BulletInteractiveChart,
  BulletCustomChart,
} from "@/components/ruixen/bullet-chart";
const data = [
  { name: "Revenue", actual: 275, target: 250, ranges: [150, 225, 300] },
  { name: "Profit", actual: 85, target: 100, ranges: [50, 75, 100] },
  { name: "Orders", actual: 180, target: 200, ranges: [100, 150, 200] },
]
 
// Default bullet chart (horizontal)
<BulletChart data={data} className="h-[200px]" />
 
// With legend
<BulletLegendChart data={data} className="h-[280px]" />
 
// Vertical layout
<BulletVerticalChart data={data} className="h-[320px]" />
 
// Interactive (hover to highlight)
<BulletInteractiveChart data={data} className="h-[240px]" />
 
// Compact single row
<BulletCompactChart
  name="Revenue"
  actual={275}
  target={250}
  ranges={[150, 225, 300]}
/>
 
// Custom colors
<BulletCustomChart
  data={data}
  rangeColors={["#e8f4ff", "#8ec5ff", "#2b7fff"]}
  actualColor="#1a5fd1"
/>

Examples

Default Bullet

The default bullet chart displays horizontal bars comparing actual values against targets with qualitative ranges (poor, satisfactory, good).

<BulletChart data={salesData} className="h-[200px]" />

With Legend

Display a legend showing actual, target, and range indicators.

<BulletLegendChart
  data={performanceData}
  legendPosition="bottom"
  className="h-[280px]"
/>

Vertical

Vertical orientation for different layout requirements.

<BulletVerticalChart data={quarterlyData} className="h-[320px]" />

Interactive

Enable hover effects to highlight individual metrics.

<BulletInteractiveChart data={kpiData} className="h-[240px]" />

Compact

Single row compact style, perfect for dashboards.

<BulletCompactChart
  name="Revenue"
  actual={275}
  target={250}
  ranges={[150, 225, 300]}
/>

Custom Colors

Use custom colors for ranges and actual values.

<BulletCustomChart
  data={data}
  rangeColors={["#e8f4ff", "#8ec5ff", "#2b7fff"]}
  actualColor="#1a5fd1"
  className="h-[280px]"
/>

Tooltip Indicators

The component supports three tooltip indicator styles matching shadcn/ui charts:

// Dot indicator (default)
<BulletChart data={data} tooltipIndicator="dot" />
 
// Line indicator
<BulletChart data={data} tooltipIndicator="line" />
 
// Dashed indicator
<BulletChart data={data} tooltipIndicator="dashed" />

Custom Value Formatter

Format values with a custom function:

<BulletChart
  data={data}
  valueFormatter={(value) => `$${value.toLocaleString()}`}
/>

Props

BulletChart

PropTypeDefaultDescription
dataBulletDataItem[]RequiredArray of bullet data items
classNamestring-Additional CSS classes
showTooltipbooleantrueShow tooltip on hover
tooltipIndicator"dot" | "line" | "dashed""dot"Tooltip indicator style
valueFormatter(value: number) => string-Custom value formatter
barSizenumber32Size of the range bars (pixels)
actualBarSizenumber12Size of the actual value bar (pixels)

BulletLegendChart

PropTypeDefaultDescription
legendPosition"top" | "bottom""bottom"Legend position

Plus all BulletChart props.

BulletVerticalChart

Same props as BulletChart. Displays bars vertically instead of horizontally.

BulletCompactChart

PropTypeDefaultDescription
namestringRequiredMetric name
actualnumberRequiredActual value
targetnumberRequiredTarget value
ranges[number, number, number]RequiredPoor, satisfactory, good
classNamestring-Additional CSS classes
valueFormatter(value: number) => string-Custom value formatter
showLabelbooleantrueShow name and values label

BulletInteractiveChart

Same props as BulletChart. Adds hover highlighting effect.

BulletCustomChart

PropTypeDefaultDescription
rangeColors[string, string, string]Default paletteColors for poor, sat, good
actualColorstring"#2b7fff"Color for actual bar
targetColorstringDefaultColor for target marker

Plus all BulletChart props.

BulletDataItem

PropertyTypeDescription
namestringMetric name
actualnumberActual/current value
targetnumberTarget/goal value
ranges[number, number, number][poor, satisfactory, good] range values