Waterfall: breaking down monthly P&L
Each bar floats between a precomputed start and end (y/y2), colored as an increase, a decrease, or a total — the classic accounting bridge between two balances.
Prerequisites
Vega-Lite v5
Vega-Lite
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{ "etape": "Capital initial", "debut": 0, "fin": 25000, "type": "total" },
{ "etape": "Janvier", "debut": 25000, "fin": 26200, "type": "hausse" },
{ "etape": "Février", "debut": 26200, "fin": 25400, "type": "baisse" },
{ "etape": "Mars", "debut": 25400, "fin": 27100, "type": "hausse" },
{ "etape": "Avril", "debut": 27100, "fin": 26500, "type": "baisse" },
{ "etape": "Mai", "debut": 26500, "fin": 28300, "type": "hausse" },
{ "etape": "Juin", "debut": 28300, "fin": 29150, "type": "hausse" },
{ "etape": "Solde final", "debut": 0, "fin": 29150, "type": "total" }
]
},
"mark": { "type": "bar", "tooltip": true },
"encoding": {
"x": { "field": "etape", "type": "nominal", "sort": null, "title": null, "axis": { "labelAngle": -30 } },
"y": { "field": "debut", "type": "quantitative", "title": "Solde ($)" },
"y2": { "field": "fin" },
"color": {
"field": "type", "type": "nominal",
"scale": { "domain": ["hausse", "baisse", "total"], "range": ["#27c93f", "#ff5f56", "#4a90d9"] },
"legend": null
}
}
}Vega-LiteWaterfally2Finance