A waterfall chart shows how an initial value is built up or eroded by a series of positive and negative contributions to reach a final total. Each bar starts exactly where the previous one ended, making cumulative effects immediately visible. It is the standard chart for P&L decomposition, budget variance analysis, and any "what changed and why" narrative.
Hovering over a bar shows a tooltip with the label, the delta value, and the running total at that point.
waterfall_chart(
data,
x,
y,
measure = NULL,
positiveColor = "#4CAF50",
negativeColor = "#F44336",
totalColor = "#5C85D6",
connector = TRUE,
connectorColor = "#aaaaaa",
showLabels = TRUE,
labelFontSize = 10,
title = NULL,
titleFontSize = 16,
xtitle = NULL,
xtitleFontSize = 13,
ytitle = NULL,
ytitleFontSize = 13,
xFontSize = 11,
yFontSize = 11,
opacity = 1,
font = "Verdana, Geneva, Tahoma, sans-serif",
bgcol = "white",
axisCol = "black",
width = NULL,
height = NULL
)The data frame containing the variables to consider.
The name of the column containing category labels.
The name of the column containing the delta values (positive for increases, negative for decreases).
Optional. The name of a column that classifies each row as
"relative" (default — a delta added to the running total) or
"total" (a bar spanning from zero to the current running total,
used for subtotals and the final total).
Fill color for bars representing an increase.
Defaults to "#4CAF50".
Fill color for bars representing a decrease.
Defaults to "#F44336".
Fill color for "total" measure bars.
Defaults to "#5C85D6".
Logical. Whether to draw dashed connector lines between
consecutive bars. Defaults to TRUE.
Color of the connector lines. Defaults to
"#aaaaaa".
Logical. Whether to display the delta value above or
below each bar. Defaults to TRUE.
Font size of the bar value labels. Defaults to
10.
Optional. Title of the chart.
Font size of the chart title. Defaults to 16.
Optional. Title of the x-axis.
Font size of the x-axis title. Defaults to 13.
Optional. Title of the y-axis.
Font size of the y-axis title. Defaults to 13.
Font size of the x-axis tick labels. Defaults to 11.
Font size of the y-axis tick labels. Defaults to 11.
Opacity of the bars (0 to 1). Defaults to 1.
The font family used for all text. Defaults to
"Verdana, Geneva, Tahoma, sans-serif".
Background color of the SVG. Defaults to "white".
Color of axis lines, ticks, and labels. Defaults to
"black".
Optional. The width of the SVG output.
Optional. The height of the SVG output.
An interactive SVG waterfall chart.
# P&L bridge: from revenue down to net income
pnl <- data.frame(
label = c("Revenue", "COGS", "Gross Profit",
"R&D", "S&M", "G&A", "Operating Income"),
value = c(1200, -450, 750, -120, -90, -60, 480),
measure = c("relative", "relative", "total",
"relative", "relative", "relative", "total")
)
waterfall_chart(
data = pnl,
x = "label",
y = "value",
measure = "measure",
title = "P&L bridge",
ytitle = "USD thousands"
)
# Monthly cash flow
cashflow <- data.frame(
month = c("Jan", "Feb", "Mar", "Apr", "May", "Jun"),
delta = c(120, -30, 80, -60, 95, -20)
)
waterfall_chart(
data = cashflow,
x = "month",
y = "delta",
title = "Monthly cash flow",
ytitle = "USD thousands",
positiveColor = "steelblue",
negativeColor = "tomato"
)