Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

ParameterTypeDefaultDescription
titlestrrequiredChart title
labelslist[str]requiredStep labels
valueslist[float]requiredStep values (positive or negative)
show_textboolTrueShow value labels on bars
color_posint0x22c55eColor for positive bars
color_negint0xef4444Color for negative bars
color_totalint0x6366f1Color for total bar
widthint900Canvas width
heightint480Canvas height
y_labelstr""Y-axis label
gridlinesboolTrueHorizontal 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ètreTypeDéfautDescription
titlestrrequisTitre du graphique
labelslist[str]requisÉtiquettes des étapes
valueslist[float]requisValeurs des étapes (positives ou négatives)
show_textboolTrueAfficher les valeurs sur les barres
color_posint0x22c55eCouleur des barres positives
color_negint0xef4444Couleur des barres négatives
color_totalint0x6366f1Couleur des barres total
widthint900Largeur du canvas
heightint480Hauteur du canvas
y_labelstr""Étiquette de l'axe Y
gridlinesboolTrueLignes 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="€",
)

Voir aussi