Waterfall
Waterfall
A waterfall chart.
Usage
from dataviz_mojo import waterfall
from dataviz_mojo.plot import save
from dataviz_mojo.theme import Theme
def main() raises:
var stages: List[String] = ["Starting", "Revenue", "COGS", "Opex", "Tax", "One-off", "Ending"]
var deltas: List[Float64] = [50.0, 32.0, -18.0, -12.0, -6.0, 4.0, 0.0]
var is_total: List[Bool] = [True, False, False, False, False, False, True]
var c = waterfall(stages, deltas, is_total=is_total)
save(c, "docs/src/examples/out_waterfall.svg")Args:
categories: One floating bar per entry, in the given order.deltas: How much the running total changes at each category – not the bar’s absolute height; each bar is drawn from the running total before it to the running total after it, starting the cumulative sum from0.0.is_total: Marks specific rows as running-total checkpoints (drawn full band width inTheme.waterfall_total_color) instead of a plain rising/falling delta. Left empty (the default), every row is a plain delta – unchanged original behavior.theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – seeTheme’s docstring.width: Pixel width of the returnedPlot(.size()).height: Pixel height of the returnedPlot(.size()).title: The chart’s title, shown above the plot.subtitle: A secondary line shown under the title.x_title: The x-axis caption.y_title: The y-axis caption.