Total bars reset to zero and show the accumulated value, useful for intermediate subtotals.
Constructor
new()
Create a waterfall chart with default settings.
Returns: WaterfallPlot
Defaults:
- Bar width
0.6 - Green/red delta colors
- Steelblue totals
- No connectors
- No value labels
Bar Types
with_delta()
Add a floating delta bar.
Category label shown on the x-axis
Increment or decrement applied to the running total. Positive values are colored green; negative values red.
Self
The bar spans from the current running total to current + value.
with_total()
Add a summary bar that spans from zero to the current running total.
Category label shown on the x-axis
Self
Rendered in color_total (default "steelblue"). The value field is ignored — the bar height is determined by the accumulated total at this position. Place after a sequence of delta bars to show a subtotal or at the end to show the final result.
with_difference()
Add a standalone comparison bar anchored at explicit y-values.
Category label shown on the x-axis
Starting y-value
Ending y-value
Self
The bar spans [from, to] and is green when to > from, red when to < from. It does not affect the running total, so it can be placed anywhere to annotate a reference comparison without disrupting the main flow.
Styling
with_bar_width()
Set the bar width as a fraction of the category slot.
Bar width in
[0.0, 1.0] (default: 0.6)Self
with_color_positive()
Set the color for positive delta bars.
CSS color string (default:
"rgb(68,170,68)" — green)Self
with_color_negative()
Set the color for negative delta bars.
CSS color string (default:
"rgb(204,68,68)" — red)Self
with_color_total()
Set the color for total/subtotal bars.
CSS color string (default:
"steelblue")Self
Annotations
with_connectors()
Draw dashed connector lines between the top (or bottom) of consecutive bars.
Returns: Self
Connectors make it easier to trace the running total across wide charts.
with_values()
Print the numeric value of each bar as a text label.
Returns: Self
Delta bars show their value; total bars show the accumulated total; difference bars show to - from.
Legend
with_legend()
Attach a legend label to this waterfall chart.
Legend label text
Self
Complete Example
WaterfallKind Enum
Variants
Delta
A floating increment or decrement applied to the running total. The bar floats between the previous running total and the new one. Positive values are colored with color_positive; negative with color_negative.
Total
A summary bar that resets to zero and spans from zero to the current running total. Colored with color_total. The value field is ignored.
Difference { from: f64, to: f64 }
A standalone comparison bar anchored at explicit [from, to] values. This bar does not affect the running total — it is purely illustrative. Green when to > from, red when to < from.
Public Fields
All bars in the chart
Bar width as a fraction of the category slot (default: 0.6)
Color for positive delta bars (default:
"rgb(68,170,68)")Color for negative delta bars (default:
"rgb(204,68,68)")Color for total/subtotal bars (default:
"steelblue")When
true, dashed connector lines are drawn between consecutive barsWhen
true, numeric values are printed on each barOptional legend label