Synertech Web/ui v0.57.5 Site Storybook

Documentation / Charts

FunnelChart

Client@synertech/uiOpen in Storybook

Ordered stages and what each one loses along the way: acquisition, hiring, a purchase journey. The stages have an order, so the colour comes from the ordinal ramp and not from the categorical colours.

The value is a length, never an area: align="center" (the default) keeps the funnel’s silhouette while the measure stays each bar’s width; align="left" turns it into a bar ranking, more precise to compare. The step-to-step ratio (showConversion, on by default) is the real finding: the absolute figures belong in the data table.

Client component ("use client") with a tooltip, an accessible table (tableView) and a click on a stage (onStageClick).

Examples

Acquisition funnel

x.key names the stages, value reads the count reached. The percentage written between two stages is the share kept from the previous one.

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

const acquisition = [
  { stage: "Visites", users: 12_400 },
  { stage: "Inscriptions", users: 6_100 },
  { stage: "Essais lancés", users: 2_300 },
  { stage: "Abonnements", users: 840 },
];

export function Basic() {
  return (
    <FunnelChart
      data={acquisition}
      x={{ key: "stage" }}
      value="users"
      title="De la visite à l’abonnement"
    />
  );
}

Left-aligned

Without the silhouette, the lengths compare more precisely: the same funnel read as a ranking.

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

const acquisition = [
  { stage: "Visites", users: 12_400 },
  { stage: "Inscriptions", users: 6_100 },
  { stage: "Essais lancés", users: 2_300 },
  { stage: "Abonnements", users: 840 },
];

export function LeftAligned() {
  return (
    <FunnelChart
      data={acquisition}
      x={{ key: "stage" }}
      value="users"
      align="left"
      title="De la visite à l’abonnement"
    />
  );
}

Long process with a table

Six stages and their data table: conversionLabel and dropOffLabel name the conversion and drop-off columns.

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

const hiring = [
  { stage: "Candidatures", people: 486 },
  { stage: "Présélection", people: 142 },
  { stage: "Entretien RH", people: 58 },
  { stage: "Entretien technique", people: 24 },
  { stage: "Offre", people: 11 },
  { stage: "Signature", people: 8 },
];

export function LongProcess() {
  return (
    <FunnelChart
      data={hiring}
      x={{ key: "stage" }}
      value="people"
      tableView="toggle"
      valueLabel="Personnes"
      conversionLabel="Conservé"
      dropOffLabel="Perdu"
      title="Tunnel de recrutement"
      description="8 signatures pour 486 candidatures"
    />
  );
}

Stage analysis on click

onStageClick receives the conversion from the previous stage and the share left from the start (overall), to open a detail next to the chart.

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

const acquisition = [
  { stage: "Visites", users: 12_400 },
  { stage: "Inscriptions", users: 6_100 },
  { stage: "Essais lancés", users: 2_300 },
  { stage: "Abonnements", users: 840 },
];

export function StageDetail() {
  const [stage, setStage] = useState<FunnelStage | null>(null);
  const percent = new Intl.NumberFormat("fr-FR", { style: "percent", maximumFractionDigits: 1 });

  return (
    <div className="flex flex-col gap-3">
      <FunnelChart
        data={acquisition}
        x={{ key: "stage" }}
        value="users"
        size="sm"
        title="Parcours d’inscription — octobre"
        onStageClick={setStage}
      />
      {stage && stage.conversion !== null && stage.overall !== null ? (
        <p className="text-sm text-gray-600 dark:text-gray-300">
          {stage.label} : {percent.format(stage.conversion)} de l’étape précédente,{" "}
          {percent.format(stage.overall)} des visiteurs.
        </p>
      ) : null}
    </div>
  );
}

API reference

Components

FunnelChart

ComponentClient

Ordered stages, and what is lost between them.

The stages have an ORDER, which is why the colour comes from the ordinal ramp and not from the categorical slots: the eight slots answer "which one", and the answer here is "the third of five". A funnel painted in identity colours says its stages are unrelated categories, which is the one thing they are not.

The value is encoded as a length, never as an area: the trapezoid silhouette of the classic funnel asks the reader to compare two surfaces, and two surfaces cannot be compared by eye. align="center" keeps the silhouette while the measure stays the width of each bar.

Use it for a path people walk in one direction. Stages that are not ordered are a BarChart, and a breakdown of one total is a PieChart.

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

Props — FunnelChartProps

PropTypeDefaultDescription
data• ChartDatum[] —

One row per stage, in the order they are walked.

value• string —

Field holding how many reached that stage.

x• ChartXAxisConfig —

Field holding the name of each stage.

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.

align "center" | "left" "center"

Where each bar sits in its row.

center is the funnel silhouette, left a plain ranked bar chart. The silhouette reads as a narrowing; the left alignment compares lengths more precisely. Both encode the value as a LENGTH — never as an area, which the eye cannot compare.

colors readonly string[] —

Replaces the ordinal ramp — any CSS colours, first stage first.

conversionLabel string —

Header of the step-to-step conversion column.

description ReactNode —
dropOffLabel string —

Header of the step-to-step loss column.

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.

onRetry () => void —

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

onStageClick (stage: FunnelStage) => 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 —
showConversion boolean true

Writes what each stage kept from the one before it.

That ratio is the reason the chart exists: the absolute figures are a table, the step-to-step loss is the finding.

showValues boolean true

Writes the figure reached at each stage.

size ChartSize "md"
stageSize number —

Caps the thickness of a stage.

tableView boolean | "toggle" false
title ReactNode —
tooltip boolean | ((stage: FunnelStage) => ReactNode) true
valueLabel string —

Header of the value column of the data table.

width number —

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

Types

FunnelStage

Interface

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

interface FunnelStage
FieldTypeDefaultDescription
conversion• number | null —

Share of the PREVIOUS stage still here. null on the first stage.

datum• ChartDatum —
dropOff• number | null —

What the previous stage lost on the way here. null on the first stage.

formattedValue• string —
index• number —
label• string —
overall• number | null —

Share of the FIRST stage still here. null on the first stage itself.

value• number | null —
x• ChartXValue —