Synertech Web/ui v0.57.5 Site Storybook

Documentation / Charts

DumbbellChart

Client@synertech/uiOpen in Storybook

Two points per item, and the distance between them: before against after, or the two ends of a range. Paired bars ask the reader to compare a difference of two lengths; here the difference is the mark, the grey rule joining the points.

The value axis is not anchored at zero: you read a gap, not a quantity. sort="gap" brings the biggest movers to the top, which turns the list into a finding. Like ScatterChart, the chart is capped at 3 series: two points of the same row can end up side by side, and only the first three palette colours stay distinguishable then (a warning is issued beyond that).

Client component ("use client"): clickable legend, tooltip, data table with a gap column (showChange).

Examples

Before / after

One series per point of the row: the first is the starting point, the last the end point.

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

const satisfaction = [
  { service: "Support", before: 62, after: 78 },
  { service: "Facturation", before: 71, after: 64 },
  { service: "Livraison", before: 44, after: 81 },
  { service: "Documentation", before: 55, after: 58 },
  { service: "Onboarding", before: 38, after: 67 },
  { service: "Mobile", before: 74, after: 72 },
];

const years = [
  { key: "before", label: "2025" },
  { key: "after", label: "2026" },
];

export function Basic() {
  return (
    <DumbbellChart
      data={satisfaction}
      x={{ key: "service" }}
      series={years}
      y={{ label: "Score de satisfaction" }}
      title="Satisfaction par service"
      description="Un an d’écart, par service"
    />
  );
}

Sorted by gap

sort="gap" orders the rows by the distance between the two ends; showValues writes the value next to each point.

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

const satisfaction = [
  { service: "Support", before: 62, after: 78 },
  { service: "Facturation", before: 71, after: 64 },
  { service: "Livraison", before: 44, after: 81 },
  { service: "Documentation", before: 55, after: 58 },
  { service: "Onboarding", before: 38, after: 67 },
  { service: "Mobile", before: 74, after: 72 },
];

const years = [
  { key: "before", label: "2025" },
  { key: "after", label: "2026" },
];

export function SortedByGap() {
  return (
    <DumbbellChart
      data={satisfaction}
      x={{ key: "service" }}
      series={years}
      sort="gap"
      showValues
      title="Ce qui a le plus bougé"
    />
  );
}

Minimum – median – maximum range

Three series per row, the component’s limit. A referenceLines entry marks the service commitment here.

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

export function Range() {
  return (
    <DumbbellChart
      data={[
        { route: "/api/search", min: 42, median: 128, max: 940 },
        { route: "/api/cart", min: 18, median: 61, max: 310 },
        { route: "/api/checkout", min: 96, median: 214, max: 1_480 },
        { route: "/api/profile", min: 12, median: 38, max: 152 },
      ]}
      x={{ key: "route" }}
      series={[
        { key: "min", label: "Min" },
        { key: "median", label: "Médiane" },
        { key: "max", label: "Max" },
      ]}
      y={{ label: "Latence (ms)" }}
      referenceLines={[{ value: 500, label: "Engagement 500 ms" }]}
      sort="gap"
      showChange={false}
      title="Latence par route"
    />
  );
}

Interactive annual review

onRowClick receives the row and its gap (change = last series minus the first); the data table adds the gap column named by changeLabel.

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

const satisfaction = [
  { service: "Support", before: 62, after: 78 },
  { service: "Facturation", before: 71, after: 64 },
  { service: "Livraison", before: 44, after: 81 },
  { service: "Documentation", before: 55, after: 58 },
  { service: "Onboarding", before: 38, after: 67 },
  { service: "Mobile", before: 74, after: 72 },
];

const years = [
  { key: "before", label: "2025" },
  { key: "after", label: "2026" },
];

export function Review() {
  const [row, setRow] = useState<DumbbellRow | null>(null);

  return (
    <div className="flex flex-col gap-3">
      <DumbbellChart
        data={satisfaction}
        x={{ key: "service" }}
        series={years}
        sort="desc"
        sortBy="after"
        tableView="toggle"
        changeLabel="Écart"
        format={(value) => `${value} pts`}
        title="Satisfaction 2026, du meilleur au moins bon"
        onRowClick={setRow}
      />
      {row && row.change !== null ? (
        <p className="text-sm text-gray-600 dark:text-gray-300">
          {row.label} : {row.change > 0 ? "+" : ""}
          {row.change} points en un an
        </p>
      ) : null}
    </div>
  );
}

API reference

Components

DumbbellChart

ComponentClient

Two points per item, and the distance between them.

Before against after, or the two ends of a range. Two paired bars answer the same question and answer it badly: the reader has to compare the difference of two lengths across a dozen rows. Here the difference IS the mark — the rule between the dots — and the eye reads it directly.

The value axis does not anchor at zero. A dumbbell is read for the gap between its two ends, and forcing zero in squeezes every gap on the chart towards nothing as soon as the values sit far from it. Pass y={{ includeZero: true }} on the rare chart where the absolute level is the point.

sort="gap" is what turns the chart from a list into a finding: the rows that moved most come to the top.

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

Props — DumbbellChartProps

PropTypeDefaultDescription
data• ChartDatum[] —

One row per item compared.

series• ChartSeries[] —

The values compared on each row — usually two: before and after.

Any two dots of a row can end up side by side, which is the same test a scatter plot puts the palette through: past three series only the first three slots stay tellable apart, and the chart says so.

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.

changeLabel string —

Header of the change column of the data table.

description ReactNode —
dotSize number 5

Radius of a dot.

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 —
grid ChartGridLines "y"
height number —
legend boolean | ChartLegendPosition —
legendToggle boolean true
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.

margin Partial<ChartMargin> —
onRetry () => void —

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

onRowClick (row: DumbbellRow) => 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 —
referenceLines ChartReferenceLine[] —
showChange boolean true

Adds the last-minus-first column to the data table.

showValues boolean false

Writes the value beside each dot, where there is room.

size ChartSize "md"
sort DumbbellSort "none"

Orders the rows. gap sorts by the distance between the two ends, which is what turns the chart from a list into a finding: the biggest movers come to the top.

sortBy string —

Series the asc / desc orders read. Defaults to the last one.

tableView boolean | "toggle" false
title ReactNode —
tooltip boolean | ((row: DumbbellRow) => ReactNode) true
width number —
y ChartYAxisConfig —

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

Functions

Resets the series warning. Test helper.

import { resetDumbbellWarnings } from "@synertech/ui";
resetDumbbellWarnings(): void

Types

DumbbellRow

Interface

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

interface DumbbellRow
FieldTypeDefaultDescription
change• number | null —

Last visible series minus first: the move the chart is read for. null while fewer than two series are visible — one value has not moved.

datum• ChartDatum —
from• number | null —

Smallest and largest value of the row, the two ends of its bar.

index• number —
label• string —
points• ChartPoint[] —

Every visible series' value on this row, in series order.

to• number | null —
x• ChartXValue —

How the rows are ordered.

type DumbbellSort = "none" | "asc" | "desc" | "gap"