BulletChart

Compact KPI chart with value, target, and qualitative ranges

Usage

BulletChart displays a value against a target on top of range bands:

import { BulletChart } from '@mantine/charts';
import { ranges } from './data';

function Demo() {
  return (
    <BulletChart
      value={230000}
      target={150000}
      ranges={ranges}
      valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
    />
  );
}

Data format

Each item in ranges sets the upper bound of a band with value and its color. The optional label names the band. It is read by screen readers and shown in the default tooltip. Visible labels always show the formatted range value.

const ranges = [
  { value: 100000, color: 'red.8', label: 'Poor' },
  { value: 200000, color: 'yellow.8', label: 'Average' },
  { value: 300000, color: 'teal.8', label: 'Good' },
];

The scale ends at the largest of the ranges, value and target. A value beyond all ranges extends the scale, and NaN or Infinity values are not displayed.

Label

Use label prop to display a label next to the chart:

import { BulletChart } from '@mantine/charts';
import { ranges } from './data';

function Demo() {
  return (
    <BulletChart
      value={230000}
      target={150000}
      ranges={ranges}
      label="Revenue"
      valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
    />
  );
}

Vertical orientation

Set orientation="vertical" to render the chart vertically. Vertical chart requires a fixed height:

import { BulletChart } from '@mantine/charts';
import { ranges } from './data';

function Demo() {
  return (
    <BulletChart
      value={230000}
      target={150000}
      ranges={ranges}
      orientation="vertical"
      valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
      h={250}
    />
  );
}

Bar color

Use barColor prop to change the value bar color and targetColor to change the target marker color:

import { BulletChart } from '@mantine/charts';
import { ranges } from './data';

function Demo() {
  return (
    <BulletChart
      value={230000}
      target={150000}
      ranges={ranges}
      barColor="black"
      targetColor="white"
      valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
    />
  );
}

Chart size

Use size prop to change the thickness of the track and barSize to change the thickness of the value bar:

import { BulletChart } from '@mantine/charts';
import { Stack } from '@mantine/core';
import { ranges } from './data';

function Demo() {
  return (
    <Stack>
      <BulletChart
        value={230000}
        target={150000}
        ranges={ranges}
        size={20}
        barSize={10}
        label="Small"
        valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
      />
      <BulletChart
        value={230000}
        target={150000}
        ranges={ranges}
        size={32}
        barSize={16}
        label="Default"
        valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
      />
      <BulletChart
        value={230000}
        target={150000}
        ranges={ranges}
        size={48}
        barSize={24}
        label="Large"
        valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
      />
    </Stack>
  );
}

Value formatter

Use valueFormatter prop to format values in labels and tooltip. Set withTooltip to display the tooltip on hover and keyboard focus:

import { BulletChart } from '@mantine/charts';
import { ranges } from './data';

function Demo() {
  return (
    <BulletChart
      value={230000}
      target={150000}
      ranges={ranges}
      withTooltip
      valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
    />
  );
}

Without target

The target marker is rendered only when the target prop is set:

import { BulletChart } from '@mantine/charts';
import { ranges } from './data';

function Demo() {
  return (
    <BulletChart
      value={230000}
      ranges={ranges}
      valueFormatter={(value) => `$${(value / 1000).toFixed(0)}k`}
    />
  );
}

Accessibility

Set aria-label to translate the chart summary or describe the value relative to its target:

<BulletChart aria-label="Ingresos: 230k, objetivo 150k" value={230000} target={150000} ranges={ranges} />