Skip to main content

Bullet

Alpha Component

Bullet is an alpha component and may undergo breaking changes. See Alpha Components for more information.

Basic Usage

import { Bullet } from '@adobe/react-spectrum-charts/alpha';

<Chart data={data}>
<Bullet
dimension="category"
metric="current"
target="goal"
/>
</Chart>

Props

nametypedefaultdescription
colorstring'categorical-100'The key in the data that is used as the color facet, or a color value.
dimensionstring'category'Data field that the metric is trended against (x-axis for horizontal orientation).
direction'row' | 'column''column'Specifies the direction the bars should be ordered (row/column).
labelPosition'side' | 'top''top'Specifies if the labels should be on top of the bullet chart or to the side. Side labels are not supported in row mode.
maxScaleValuenumberMaximum value for the scale. This value must be greater than zero.
metricstring'value'Key in the data that is used as the metric.
metricLabelstringKey in the data that contains a pre-formatted label for the metric value. When provided, this formatted label will be displayed instead of applying numberFormat to the metric value.
metricAxisbooleanfalseAdds an axis that follows the max target in basic mode.
namestringSets the name of the component.
numberFormatstring'standardNumber'd3 number format specifier or shorthand ('currency', 'shortCurrency', 'shortNumber', 'standardNumber'). Sets the number format for the summary value. See d3-format.
scaleType'normal' | 'fixed' | 'flexible''normal'

In normal mode the maximum scale value will be calculated using the maximum value of the metric and target data fields.

In fixed mode the maximum scale value will be set as the maxScaleValue prop.

In flexible mode the maximum scale value will be calculated using the maximum value of either the maxScaleValue prop or maximum value of the metric and target data fields.

showTargetbooleantrueFlag to control whether the target line is shown.
showTargetValuebooleanfalseFlag to control whether the target value label is shown.
targetstring'target'Key in the data for the target line value.
targetLabelstringKey in the data that contains a pre-formatted label for the target value. When provided, this formatted label will be displayed instead of applying numberFormat to the target value.
thresholdBarColorbooleanfalseIf true, the metric bar will be colored according to the thresholds.
thresholdsThresholdBackground[]

Array of threshold definitions to be rendered as background bands on the bullet chart.
Each threshold object supports:
thresholdMin (optional): The lower bound of the threshold
thresholdMax (optional): The upper bound of the threshold
fill: The fill color to use for the threshold background

trackbooleanfalseAdds color regions that sit behind the bullet bar.

Custom Label Formatting

The metricLabel and targetLabel props allow you to provide pre-formatted labels in your data, giving you complete control over label formatting including custom units, localization, or annotations.

Example with Custom Labels

const data = [
{
category: 'Storage Used',
current: 750,
currentLabel: '750 GB',
goal: 1000,
goalLabel: '1 TB',
},
{
category: 'API Requests',
current: 850,
currentLabel: '85K req/sec',
goal: 1000,
goalLabel: '100K req/sec',
},
];

<Chart data={data}>
<Bullet
dimension="category"
metric="current"
metricLabel="currentLabel"
target="goal"
targetLabel="goalLabel"
/>
</Chart>

This is useful when you need:

  • Custom units that aren't in standard number formats
  • Localized formatting from external libraries
  • Context-specific annotations
  • Different formatting per data point

Thresholds

Thresholds create colored background regions to indicate performance zones:

const thresholds = [
{ thresholdMax: 600, fill: 'rgb(21, 164, 110)' }, // green
{ thresholdMin: 600, thresholdMax: 900, fill: 'rgb(249, 137, 23)' }, // orange
{ thresholdMin: 900, fill: 'rgb(234, 56, 41)' }, // red
];

<Chart data={data}>
<Bullet
dimension="category"
metric="current"
target="goal"
thresholds={thresholds}
thresholdBarColor={true}
/>
</Chart>

When thresholdBarColor is enabled, the bullet bar itself will be colored based on which threshold zone it falls into.