Waterfall Chart
Signature
sp.build_waterfall(
title: str,
labels: list[str],
values: list[float],
*,
show_text: bool = True,
width: int = 900,
height: int = 480,
x_label: str = "",
y_label: str = "",
color_pos: int = 0x22c55e,
color_neg: int = 0xef4444,
color_total: int = 0x6366f1,
palette: list[int] | None = None,
background: str | None = None,
gridlines: bool = True,
) -> Chart
Aliases: sp.waterfall
Description
Waterfall chart showing sequential positive and negative contributions to a running total. The last bar can act as the cumulative total.
Positive values rise, negative values fall. The last bar typically represents the final total.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
title | str | required | Chart title |
labels | list[str] | required | Step labels |
values | list[float] | required | Step values (positive or negative) |
show_text | bool | True | Show value labels on bars |
color_pos | int | 0x22c55e | Color for positive bars |
color_neg | int | 0xef4444 | Color for negative bars |
color_total | int | 0x6366f1 | Color for total bar |
width | int | 900 | Canvas width |
height | int | 480 | Canvas height |
y_label | str | "" | Y-axis label |
gridlines | bool | True | Horizontal gridlines |
Returns
Chart
Examples
P&L breakdown
import seraplot as sp
chart = sp.build_waterfall(
"Annual P&L Waterfall",
labels=["Revenue", "COGS", "Gross Profit", "OpEx", "EBITDA", "D&A", "Net Income"],
values=[100000, -45000, 0, -30000, 0, -5000, 0],
show_text=True,
y_label="$",
)const sp = require('seraplot');
const chart = sp.build_waterfall("Annual P&L Waterfall",
["Revenue", "COGS", "Gross Profit", "OpEx", "EBITDA", "D&A", "Net Income"],
{
values: [100000, -45000, 0, -30000, 0, -5000, 0],
show_text: true,
y_label: "$"
})import * as sp from 'seraplot';
const chart = sp.build_waterfall("Annual P&L Waterfall",
["Revenue", "COGS", "Gross Profit", "OpEx", "EBITDA", "D&A", "Net Income"],
{
values: [100000, -45000, 0, -30000, 0, -5000, 0],
show_text: true,
y_label: "$"
})▶ Live Preview
See also
Signature
sp.build_waterfall(
title: str,
labels: list[str],
values: list[float],
*,
show_text: bool = True,
width: int = 900,
height: int = 480,
x_label: str = "",
y_label: str = "",
color_pos: int = 0x22c55e,
color_neg: int = 0xef4444,
color_total: int = 0x6366f1,
palette: list[int] | None = None,
background: str | None = None,
gridlines: bool = True,
) -> Chart
Aliases: sp.waterfall
Description
Graphique en cascade montrant les contributions positives et négatives séquentielles à un total cumulatif. Les valeurs positives montent, les négatives descendent. La dernière barre représente généralement le total final.
Paramètres
| Paramètre | Type | Défaut | Description |
|---|---|---|---|
title | str | requis | Titre du graphique |
labels | list[str] | requis | Étiquettes des étapes |
values | list[float] | requis | Valeurs des étapes (positives ou négatives) |
show_text | bool | True | Afficher les valeurs sur les barres |
color_pos | int | 0x22c55e | Couleur des barres positives |
color_neg | int | 0xef4444 | Couleur des barres négatives |
color_total | int | 0x6366f1 | Couleur des barres total |
width | int | 900 | Largeur du canvas |
height | int | 480 | Hauteur du canvas |
y_label | str | "" | Étiquette de l'axe Y |
gridlines | bool | True | Lignes de grille horizontales |
Retourne
Chart
Exemples
Compte de résultat
import seraplot as sp
chart = sp.build_waterfall(
"Cascade Résultat annuel",
labels=["Chiffre d'affaires", "Coût des ventes", "Marge brute", "Charges", "EBITDA", "D&A", "Résultat net"],
values=[100000, -45000, 0, -30000, 0, -5000, 0],
show_text=True,
y_label="€",
)