Synertech Web/ui v0.57.5 Site Storybook

Documentation / Charts

BulletChart

Client@synertech/uiOpen in Storybook

What was reached, what was aimed at and what counts as good, on a single line: the densest readout of the kit. The bar is the actual, the vertical tick the target, the grey background bands the qualitative ranges. BulletChart completes StatCard rather than competing with it: the card gives a figure and its change, the bullet its position against its target.

Each row has its own scale by default (normalize="row"), which lets a revenue in euros and an NPS out of 100 share a panel; the trade-off is that there is no common axis. normalize="shared" (or a fixed domain) puts every row back on a single scale and brings the value axis back, when they carry the same unit.

The ranges stay grey and never on the ordinal ramp: that ramp is blue, like the measure bar. Client component ("use client"), with a tooltip, an accessible data table (tableView) and keyboard parity.

Examples

Quarterly targets

value is the actual, target the target, ranges an ascending array of bounds. Each row is scaled on its own.

Open in a tab
import { BulletChart } from "@synertech/ui";

const objectives = [
  { measure: "Revenu", value: 38400, target: 42000, bands: [20000, 34000, 50000] },
  { measure: "Marge brute (%)", value: 26, target: 32, bands: [15, 25, 40] },
  { measure: "NPS", value: 61, target: 50, bands: [20, 40, 70] },
  { measure: "Tickets résolus", value: 412, target: 380, bands: [200, 350, 500] },
];

export function Basic() {
  return (
    <BulletChart
      data={objectives}
      x={{ key: "measure" }}
      value="value"
      target="target"
      ranges="bands"
      title="Où en est le trimestre"
      description="Barre = réalisé · trait = objectif · fond = plages"
    />
  );
}

Shared scale

When every row carries the same unit, normalize="shared" aligns them on a single scale and draws the value axis.

Open in a tab
import { BulletChart } from "@synertech/ui";

const regions = [
  { region: "Bretagne", sold: 184, quota: 220, bands: [100, 180, 260] },
  { region: "Occitanie", sold: 262, quota: 240, bands: [100, 180, 260] },
  { region: "Grand Est", sold: 96, quota: 150, bands: [100, 180, 260] },
  { region: "Normandie", sold: 201, quota: 200, bands: [100, 180, 260] },
];

export function SharedScale() {
  return (
    <BulletChart
      data={regions}
      x={{ key: "region", label: "Unités vendues" }}
      value="sold"
      target="quota"
      ranges="bands"
      normalize="shared"
      title="Ventes par région"
    />
  );
}

Without ranges, formatted values

Ranges are optional: the reading then rests on the distance between the bar and the tick alone. A fixed domain imposes the 0–100% scale on every row, and format sets how the figures are written.

Open in a tab
import { BulletChart } from "@synertech/ui";

export function WithoutRanges() {
  const percent = new Intl.NumberFormat("fr-FR", { style: "percent" });

  return (
    <BulletChart
      data={[
        { team: "Support", rate: 0.82, goal: 0.9 },
        { team: "Ventes", rate: 0.64, goal: 0.75 },
        { team: "Produit", rate: 0.93, goal: 0.85 },
      ]}
      x={{ key: "team" }}
      value="rate"
      target="goal"
      domain={[0, 1]}
      format={(value) => percent.format(value)}
      title="Taux de réponse aux enquêtes"
    />
  );
}

Interactive dashboard

onRowClick receives the row with its attainment rate (attainment); the data table is reachable behind a button through tableView="toggle".

Open in a tab
import { useState } from "react";
import { BulletChart, type BulletRow } from "@synertech/ui";

const objectives = [
  { measure: "Revenu", value: 38400, target: 42000, bands: [20000, 34000, 50000] },
  { measure: "Marge brute (%)", value: 26, target: 32, bands: [15, 25, 40] },
  { measure: "NPS", value: 61, target: 50, bands: [20, 40, 70] },
  { measure: "Tickets résolus", value: 412, target: 380, bands: [200, 350, 500] },
];

export function Dashboard() {
  const [selected, setSelected] = useState<BulletRow | null>(null);

  return (
    <div className="flex flex-col gap-3">
      <BulletChart
        data={objectives}
        x={{ key: "measure" }}
        value="value"
        target="target"
        ranges="bands"
        tableView="toggle"
        valueLabel="Réalisé"
        targetLabel="Objectif"
        locale="fr-FR"
        title="Objectifs T3"
        onRowClick={setSelected}
      />
      {selected ? (
        <p className="text-sm text-gray-600 dark:text-gray-300">
          {selected.label} : {selected.formattedValue} sur {selected.formattedTarget}
          {selected.attainment !== null
            ? ` (${Math.round(selected.attainment * 100)} % de l’objectif)`
            : null}
        </p>
      ) : null}
    </div>
  );
}

Loading and error states

loading, error and onRetry are part of the charts’ common contract: a failed request is never shown as "no data".

Open in a tab
import { useState } from "react";
import { BulletChart } from "@synertech/ui";

const objectives = [
  { measure: "Revenu", value: 38400, target: 42000, bands: [20000, 34000, 50000] },
  { measure: "Marge brute (%)", value: 26, target: 32, bands: [15, 25, 40] },
  { measure: "NPS", value: 61, target: 50, bands: [20, 40, 70] },
  { measure: "Tickets résolus", value: 412, target: 380, bands: [200, 350, 500] },
];

export function LoadingAndError() {
  const [failed, setFailed] = useState(true);

  return (
    <BulletChart
      data={failed ? [] : objectives}
      x={{ key: "measure" }}
      value="value"
      target="target"
      ranges="bands"
      error={failed}
      onRetry={() => setFailed(false)}
      title="Objectifs du trimestre"
    />
  );
}

API reference

Components

BulletChart

ComponentClient

What was reached, what was aimed at, and what counts as good — on one line.

The densest readout of the kit: three measures fit where three gauges would take the page. It completes StatCard rather than competing with it — the card gives a figure and how it moved, the bullet gives where it stands against its target.

Each row is scaled on its own by default, which is what lets a revenue in dollars and an NPS out of 100 share a panel. That also means there is no common axis to read across rows: pass normalize="shared" (or a domain) when the rows carry the same unit, and the value axis comes back.

import { BulletChart } from "@synertech/ui";

Props — BulletChartProps

PropTypeDefaultDescription
data• ChartDatum[] —

One row per measure.

value• string —

Field holding the figure reached.

x• ChartXAxisConfig —

Field holding the name of each row.

actions ReactNode —

Slot on the right of the caption: an export button, a range picker.

A filter that frames several panels belongs in a ChartFilterBar above all of them; this is for what belongs to this panel alone.

color string —

Colour of the measure bar. Defaults to the first palette slot.

description ReactNode —
domain [number, number] —

Fixed bounds for every row. Implies a shared scale and a value axis.

emptyState ReactNode —

Replaces the "no data" state: usually an EmptyState saying why, and what to do.

error boolean false

The data could not be loaded.

Never the same thing as having none: a panel that says "no data" after a failed request states something false, and offers no way out.

errorState ReactNode —

Replaces the whole built-in error state, message and button included.

format (value: number) => string —
height number —
loading boolean false

Dims the plot while fresh data loads; a first load shows a spinner.

locale string —

BCP 47 tag the numbers and the dates are written in. Defaults to the locale of UILabelsProvider, then to the language of the runtime.

normalize "row" | "shared" "row"

row gives each row its own scale, which is what lets a revenue and an NPS share a panel. shared puts them all on one scale and draws the value axis — only meaningful when the rows carry the same unit.

onRetry () => void —

Draws the retry button in the error state, and is called when pressed.

onRowClick (row: BulletRow) => void —

Called with the mark that was clicked.

Enter and Space on the focused chart do the same for the mark the keyboard is on.

plotLabel string —
rangeColors readonly string[] —

Replaces the range greys — any CSS colours, darkest first.

ranges string —

Field holding the qualitative range boundaries — an ascending array of numbers, painted as grey bands behind the bar.

showValues boolean true

Writes the figure reached after each track.

size ChartSize "md"
tableView boolean | "toggle" false
target string —

Field holding the figure aimed at. Drawn as a tick across the track.

targetLabel string —

Header of the target column of the data table.

title ReactNode —
tooltip boolean | ((row: BulletRow) => ReactNode) true
trackSize number —

Thickness of a track.

valueLabel string —

Header of the value column of the data table, and caption of the value axis when there is one (a shared or fixed domain). x.label names the rows, never the measure.

width number —

+ 276 inherited native attributes from HTMLAttributes, AriaAttributes, DOMAttributes (className, id, aria-*, event handlers…).

Types

BulletRow

Interface

One measure, as the tooltip and the click handler see it.

interface BulletRow
FieldTypeDefaultDescription
attainment• number | null —

value / target, or null when either is missing.

datum• ChartDatum —
formattedTarget• string —
formattedValue• string —
index• number —
label• string —
ranges• number[] —
target• number | null —
value• number | null —
x• ChartXValue —