# Bullet Chart

> Compare a measure with a target against qualitative ranges, one compact row per metric.

Source: https://www.honestui.com/docs/charts/bullet-chart/static

### Sales performance against targets

```tsx
"use client";

import { BulletChart, type ChartConfig } from "honestui/charts";

// Scenario: Quarterly sales performance against targets
const data = [
  { metric: "Revenue", unit: "USD, thousands", actual: 271, target: 250, ranges: [150, 225, 300] },
  { metric: "Profit", unit: "%", actual: 22.5, target: 26, ranges: [20, 25, 30] },
  { metric: "Avg. order", unit: "USD", actual: 318, target: 550, ranges: [350, 500, 600] },
  { metric: "New customers", unit: "Count", actual: 1640, target: 2100, ranges: [1400, 2000, 2500] },
  { metric: "Satisfaction", unit: "Out of 5", actual: 4.4, target: 4.2, ranges: [3.5, 4.25, 5] },
];

const chartConfig = {
  actual: { label: "Actual", colors: { light: ["#2563eb"], dark: ["#3b82f6"] } },
  target: { label: "Target", colors: { light: ["#0a0a0a"], dark: ["#fafafa"] } },
} satisfies ChartConfig;

export function ExampleBulletChart() {
  return (
    <BulletChart
      data={data}
      config={chartConfig}
      labelDataKey="metric"
      descriptionDataKey="unit"
      valueDataKey="actual"
      targetDataKey="target"
      rangesDataKey="ranges"
      rangeLabels={["Poor", "Satisfactory", "Good"]}
      className="h-full w-full p-4"
    >
      <BulletChart.Legend />
      <BulletChart.Tooltip />
      <BulletChart.Axis />
      <BulletChart.Ranges />
      <BulletChart.Measure />
      <BulletChart.Target />
    </BulletChart>
  );
}

```

## Overview [#overview]

A bullet chart, designed by Stephen Few, packs a gauge's information into a single row: the measure is a bar, the target is a tick across it, and shaded bands behind it mark qualitative ranges such as poor, satisfactory, and good. Stack several rows to review many metrics in the space of one gauge.

Each row has its own scale, so revenue in thousands, profit in percent, and satisfaction out of five can sit side by side. Do not compare bar lengths between rows; compare each bar with its own target and bands.

## Anatomy [#anatomy]

`BulletChart` turns each data row into a bullet with a title, an optional description line, and a scale running from zero to the row's maximum. The maximum is the last range threshold, the value, or the target, whichever is largest, unless `maxDataKey` sets it. Compose the parts you need: `Ranges` draws the bands, `Measure` the bar, `Target` the tick, and `Axis` the per-row tick labels. Add `Tooltip` and `Legend` for detail.

The bands run from darkest to lightest using shades of the foreground color, as Few recommends, so they stay readable in grayscale and never compete with the measure's color.

## Accessibility [#accessibility]

The default `ariaLabel` reads every row's value and target, so a screen reader hears the whole comparison without the canvas. Name ranges with `rangeLabels` so the tooltip can say which band a value falls in. If being over or under target matters, say it in nearby text too: the tick's position alone is a subtle cue.

## Installation [#installation]

<CommandBlock commands="[&#x22;honestui&#x22;]" />

## Usage [#usage]

```tsx
import { BulletChart, type ChartConfig } from "honestui/charts";
```

```tsx
const data = [
  { metric: "Revenue", unit: "USD, thousands", actual: 271, target: 250, ranges: [150, 225, 300] },
  { metric: "Profit", unit: "%", actual: 22.5, target: 26, ranges: [20, 25, 30] },
];

<BulletChart
  data={data}
  config={chartConfig}
  labelDataKey="metric"
  descriptionDataKey="unit"
  valueDataKey="actual"
  targetDataKey="target"
  rangesDataKey="ranges"
  rangeLabels={["Poor", "Satisfactory", "Good"]}
>
  <BulletChart.Tooltip />
  <BulletChart.Axis />
  <BulletChart.Ranges />
  <BulletChart.Measure />
  <BulletChart.Target />
</BulletChart>
```

Range thresholds are ascending upper bounds: `[150, 225, 300]` draws bands from 0 to 150, 150 to 225, and 225 to 300. Give the chart roughly 56px per row with an axis, or 36px without one.

## Examples [#examples]

### Compact [#compact]

### No axis, thicker measure

```tsx
"use client";

import { BulletChart, type ChartConfig } from "honestui/charts";

// Scenario: Service latency budgets, with no axis for a dense dashboard tile
const data = [
  { service: "Checkout API", p95: 184, budget: 250, ranges: [200, 300, 400] },
  { service: "Search", p95: 342, budget: 300, ranges: [200, 300, 400] },
  { service: "Auth", p95: 96, budget: 150, ranges: [200, 300, 400] },
  { service: "Recommendations", p95: 268, budget: 250, ranges: [200, 300, 400] },
];

const chartConfig = {
  p95: { label: "p95 latency", colors: { light: ["#7c3aed"], dark: ["#a78bfa"] } },
  budget: { label: "Budget", colors: { light: ["#ea580c"], dark: ["#fb923c"] } },
} satisfies ChartConfig;

export function ExampleCompactBulletChart() {
  return (
    <BulletChart
      data={data}
      config={chartConfig}
      labelDataKey="service"
      valueDataKey="p95"
      targetDataKey="budget"
      rangesDataKey="ranges"
      rangeLabels={["Fast", "Acceptable", "Slow"]}
      labelWidth={136}
      className="h-full w-full p-4"
    >
      <BulletChart.Tooltip valueFormatter={(value) => `${value} ms`} />
      <BulletChart.Ranges />
      <BulletChart.Measure thickness={0.5} radius={2} />
      <BulletChart.Target length={0.9} />
    </BulletChart>
  );
}

```

Leave out `Axis` for a dense tile, and raise the measure's `thickness` and the target's `length` so the rows stay legible at a small size. Here every row shares the same thresholds, so one set of range labels describes them all.

### Loading State [#loading-state]

### isLoading='true'

```tsx
"use client";

import { BulletChart, type ChartConfig } from "honestui/charts";

const chartConfig = {
  actual: { label: "Actual", colors: { light: ["#2563eb"], dark: ["#3b82f6"] } },
  target: { label: "Target", colors: { light: ["#0a0a0a"], dark: ["#fafafa"] } },
} satisfies ChartConfig;

export function ExampleLoadingBulletChart() {
  return (
    <BulletChart
      data={[]}
      config={chartConfig}
      labelDataKey="metric"
      valueDataKey="actual"
      targetDataKey="target"
      isLoading
      className="h-full w-full p-4"
    >
      <BulletChart.Ranges />
      <BulletChart.Measure />
      <BulletChart.Target />
    </BulletChart>
  );
}

```

`isLoading` draws neutral placeholder rows with the shared loading label.

## API Reference [#api-reference]

<ApiHeading>
  BulletChart
</ApiHeading>


  ### `data`

type: `TData[]`

One row per bullet.

  ### `config`

type: `ChartConfig`

Labels and colors for the measure and target keys. Without a target color, the tick uses the foreground color.

  ### `labelDataKey`

type: `keyof TData & string`

The row title.

  ### `valueDataKey`

type: `keyof TData & string`

The measure drawn as the bar.

  ### `descriptionDataKey`

type: `keyof TData & string`

A second line under the title, such as a unit.

  ### `targetDataKey`

type: `keyof TData & string`

The comparative measure drawn as the tick.

  ### `rangesDataKey`

type: `keyof TData & string`

A field holding ascending range thresholds.

  ### `maxDataKey`

type: `keyof TData & string`

A field that sets each row's scale maximum.

  ### `rangeLabels`

type: `string[]`

Names for the ranges, from the first threshold up, shown in the tooltip.

  ### `labelWidth`

type: `number` · default: `128`

Width of the label column in pixels.

  ### `animation`

type: `boolean` · default: `true`

Grows each measure in, row by row. Reduced-motion preferences turn it off.

  ### `isLoading`

type: `boolean` · default: `false`

Shows placeholder rows and the loading label.

  ### `ariaLabel`

type: `string`

Accessible name for the canvas. Every row's value and target are read when omitted.

  ### `chartOptions`



">
    Escape hatch merged over the generated ECharts option.


<ApiHeading>
  Measure
</ApiHeading>


  ### `thickness`

type: `number` · default: `0.36`

Bar thickness as a share of the range band.

  ### `radius`

type: `number` · default: `1`

Corner radius in pixels.


<ApiHeading>
  Target
</ApiHeading>


  ### `length`

type: `number` · default: `0.72`

Tick length as a share of the range band.

  ### `width`

type: `number` · default: `2`

Tick width in pixels.


<ApiHeading>
  Ranges
</ApiHeading>

`BulletChart.Ranges` takes no props. Include it to draw the qualitative bands.

<ApiHeading>
  Axis
</ApiHeading>


  ### `tickCount`

type: `number` · default: `4`

About how many ticks each row shows.

  ### `tickFormatter`



string">
    Formats tick labels. Receives the row index, since each row can use a different unit.


<ApiHeading>
  Tooltip
</ApiHeading>


  ### `valueFormatter`



string">
    Formats the value and target.

  ### `variant`

type: `&#x22;default&#x22; | &#x22;frosted-glass&#x22;` · default: `&#x22;default&#x22;`

Tooltip surface.

  ### `roundness`

type: `&#x22;sm&#x22; | &#x22;md&#x22; | &#x22;lg&#x22; | &#x22;xl&#x22;` · default: `&#x22;lg&#x22;`

Tooltip corner radius.


<ApiHeading>
  Legend
</ApiHeading>


  ### `variant`

type: `LegendVariant` · default: `&#x22;rounded-square&#x22;`

Indicator shape.

  ### `align`

type: `&#x22;left&#x22; | &#x22;center&#x22; | &#x22;right&#x22;` · default: `&#x22;right&#x22;`

Horizontal alignment.

  ### `verticalAlign`

type: `&#x22;top&#x22; | &#x22;bottom&#x22;` · default: `&#x22;top&#x22;`

Vertical placement.
