Waterfall
Overview
The waterfall
trace type is used to create waterfall charts, which are useful for visualizing incremental changes in value over a series of categories or time. Waterfall charts are commonly used in financial and analytical contexts to show how sequential positive or negative values affect an initial value.
You can customize the colors, connectors, and base values to represent your data effectively.
Common Uses
- Financial Analysis: Visualizing profit and loss over time or across categories.
- Incremental Changes: Showing how individual positive or negative changes affect a starting value.
- Part-to-Whole Visualization: Highlighting how parts contribute to a cumulative total.
Check out the Attributes for the full set of configuration options
Examples
Common Configurations
Here's a simple waterfall
plot showing incremental changes across categories:
You can copy this code below to create this chart in your project:
models:
- name: waterfall-data
args:
- echo
- |
idx,label,value
0,Starting,1000
1,Increase A,200
2,Decrease B,-150
3,Increase C,300
4,Ending,1350
traces:
- name: Simple Waterfall Plot
model: ${ref(waterfall-data)}
props:
type: waterfall
x: ?{label}
y: ?{value}
measure: ["initial", "relative", "relative", "relative", "total"]
order_by:
- ?{ idx asc}
charts:
- name: Simple Waterfall Chart
traces:
- ${ref(Simple Waterfall Plot)}
layout:
title:
text: Simple Waterfall Plot<br><sub>Sequential Changes in Value</sub>
This example demonstrates a waterfall
plot where the bars have custom colors for different categories:
Here's the code:
models:
- name: waterfall-data-colors
args:
- echo
- |
idx,label,value,color
0,Starting,1000,#1f77b4
1,Increase A,200,#2ca02c
2,Decrease B,-150,#d62728
3,Increase C,300,#ff7f0e
4,Ending,1350,#9467bd
traces:
- name: Waterfall Plot with Custom Colors
model: ${ref(waterfall-data-colors)}
props:
type: waterfall
x: ?{label}
y: ?{value}
measure: ["initial", "relative", "relative", "relative", "total"]
increasing:
marker:
color: 'orange'
decreasing:
marker:
color: 'purple'
totals:
marker:
color: 'grey'
line:
color: 'orange'
width: 4
order_by:
- ?{ idx asc}
charts:
- name: Waterfall Chart with Custom Colors
traces:
- ${ref(Waterfall Plot with Custom Colors)}
layout:
title:
text: Waterfall Plot with Custom Colors<br><sub>Customized Coloring for Categories</sub>
Here's a waterfall
plot demonstrating a financial use case with connectors and custom formatting:
Here's the code:
models:
- name: waterfall-data-connectors
args:
- echo
- |
idx,quarter,half,value,mode
0,Q1,H1,1000,initial
1,Q2,H1,200,relative
2,Gross Profit,H1 Summary,0,total
3,Q3,H2,-150,relative
4,Q4,H2,300,relative
5,Gross Profit,FY2024,0,total
traces:
- name: Waterfall Plot with Connectors
model: ${ref(waterfall-data-connectors)}
props:
type: waterfall
x:
- ?{half}
- ?{quarter}
y: ?{value}
measure: ?{mode}
hovertemplate: "%{x}: %{y:$.2f}"
texttemplate: "%{delta:$.2f}"
textposition: "outside"
connector:
line:
color: "orange"
width: 5
order_by:
- ?{ idx asc}
charts:
- name: Waterfall Chart with Connectors
traces:
- ${ref(Waterfall Plot with Connectors)}
layout:
title:
text: Financial Waterfall
margin:
b: 50
t: 60
yaxis:
range: [0, 1600]
tickprefix: '$'
title:
text: "Millions ($)"
A schema to validate plotly trace properties
Attributes
These attributes apply to traces where trace.props.type
is set to waterfall
. You would configure these attributes on the trace with the trace.props
object.
alignmentgroup: 'string' #(1)!
base: number
cliponaxis: boolean
connector:
line:
color: any
dash: 'string' #(2)!
width: number
mode: any
visible: boolean
constraintext: any
customdata: array
customdatasrc: 'string' #(3)!
decreasing:
marker:
color: any
line:
color: any
width: number
dx: number
dy: number
hoverinfo: array
hoverinfosrc: 'string' #(4)!
hoverlabel:
align: array
alignsrc: 'string' #(5)!
bgcolor: array
bgcolorsrc: 'string' #(6)!
bordercolor: array
bordercolorsrc: 'string' #(7)!
font:
color: array
colorsrc: 'string' #(8)!
family: 'string | array' #(9)!
familysrc: 'string' #(10)!
lineposition: array
linepositionsrc: 'string' #(11)!
shadow: 'string | array' #(12)!
shadowsrc: 'string' #(13)!
size: array
sizesrc: 'string' #(14)!
style: array
stylesrc: 'string' #(15)!
textcase: array
textcasesrc: 'string' #(16)!
variant: array
variantsrc: 'string' #(17)!
weight: array
weightsrc: 'string' #(18)!
namelength: array
namelengthsrc: 'string' #(19)!
hovertemplate: 'string | array' #(20)!
hovertemplatesrc: 'string' #(21)!
hovertext: 'string | array' #(22)!
hovertextsrc: 'string' #(23)!
ids: array
idssrc: 'string' #(24)!
increasing:
marker:
color: any
line:
color: any
width: number
insidetextanchor: any
insidetextfont:
color: array
colorsrc: 'string' #(25)!
family: 'string | array' #(26)!
familysrc: 'string' #(27)!
lineposition: array
linepositionsrc: 'string' #(28)!
shadow: 'string | array' #(29)!
shadowsrc: 'string' #(30)!
size: array
sizesrc: 'string' #(31)!
style: array
stylesrc: 'string' #(32)!
textcase: array
textcasesrc: 'string' #(33)!
variant: array
variantsrc: 'string' #(34)!
weight: array
weightsrc: 'string' #(35)!
legend: string
legendgroup: 'string' #(36)!
legendgrouptitle:
font:
color: any
family: 'string' #(37)!
lineposition: any
shadow: 'string' #(38)!
size: number
style: any
textcase: any
variant: any
weight: integer
text: 'string' #(39)!
legendrank: number
legendwidth: number
measure: array
measuresrc: 'string' #(40)!
metasrc: 'string' #(41)!
name: 'string' #(42)!
offset: array
offsetgroup: 'string' #(43)!
offsetsrc: 'string' #(44)!
opacity: number
orientation: any
outsidetextfont:
color: array
colorsrc: 'string' #(45)!
family: 'string | array' #(46)!
familysrc: 'string' #(47)!
lineposition: array
linepositionsrc: 'string' #(48)!
shadow: 'string | array' #(49)!
shadowsrc: 'string' #(50)!
size: array
sizesrc: 'string' #(51)!
style: array
stylesrc: 'string' #(52)!
textcase: array
textcasesrc: 'string' #(53)!
variant: array
variantsrc: 'string' #(54)!
weight: array
weightsrc: 'string' #(55)!
showlegend: boolean
stream:
maxpoints: number
token: 'string' #(56)!
text: 'string | array' #(57)!
textangle: number
textfont:
color: array
colorsrc: 'string' #(58)!
family: 'string | array' #(59)!
familysrc: 'string' #(60)!
lineposition: array
linepositionsrc: 'string' #(61)!
shadow: 'string | array' #(62)!
shadowsrc: 'string' #(63)!
size: array
sizesrc: 'string' #(64)!
style: array
stylesrc: 'string' #(65)!
textcase: array
textcasesrc: 'string' #(66)!
variant: array
variantsrc: 'string' #(67)!
weight: array
weightsrc: 'string' #(68)!
textinfo: any
textposition: array
textpositionsrc: 'string' #(69)!
textsrc: 'string' #(70)!
texttemplate: 'string | array' #(71)!
texttemplatesrc: 'string' #(72)!
totals:
marker:
color: any
line:
color: any
width: number
type: waterfall
uid: 'string' #(73)!
visible: any
width: array
widthsrc: 'string' #(74)!
x: array
xaxis: string
xhoverformat: 'string' #(75)!
xperiodalignment: any
xsrc: 'string' #(76)!
y: array
yaxis: string
yhoverformat: 'string' #(77)!
yperiodalignment: any
ysrc: 'string' #(78)!
zorder: integer
- Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently.
- Sets the dash style of lines. Set to a dash type string (solid, dot, dash, longdash, dashdot, or longdashdot) or a dash length list in px (eg 5px,10px,2px,2px).
- Sets the source reference on Chart Studio Cloud for
customdata
. - Sets the source reference on Chart Studio Cloud for
hoverinfo
. - Sets the source reference on Chart Studio Cloud for
align
. - Sets the source reference on Chart Studio Cloud for
bgcolor
. - Sets the source reference on Chart Studio Cloud for
bordercolor
. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
namelength
. - Template string used for rendering the information that appear on hover box. Note that this will override
hoverinfo
. Variables are inserted using %{variable}, for example "y: %{y}" as well as %{xother}, {%xother}, {%_xother}, {%xother_}. When showing info for several points, xother will be added to those with different x positions from the first point. An underscore before or after (x|y)other will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. The variables available inhovertemplate
are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that arearrayOk: true
) are available. Finally, the template string has access to variablesinitial
,delta
andfinal
. Anything contained in tag<extra>
is displayed in the secondary box, for example "{fullData.name} ". To hide the secondary box completely, use an empty tag<extra></extra>
. - Sets the source reference on Chart Studio Cloud for
hovertemplate
. - Sets hover text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. To be seen, trace
hoverinfo
must contain a text flag. - Sets the source reference on Chart Studio Cloud for
hovertext
. - Sets the source reference on Chart Studio Cloud for
ids
. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the legend group for this trace. Traces and shapes part of the same legend group hide/show at the same time when toggling legend items.
- HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the title of the legend group.
- Sets the source reference on Chart Studio Cloud for
measure
. - Sets the source reference on Chart Studio Cloud for
meta
. - Sets the trace name. The trace name appears as the legend item and on hover.
- Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up.
- Sets the source reference on Chart Studio Cloud for
offset
. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - The stream id number links a data trace on a plot with a stream. See https://chart-studio.plotly.com/settings for more details.
- Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace
hoverinfo
contains a text flag and hovertext is not set, these elements will be seen in the hover labels. - Sets the source reference on Chart Studio Cloud for
color
. - HTML font family - the typeface that will be applied by the web browser. The web browser can only apply a font if it is available on the system where it runs. Provide multiple font families, separated by commas, to indicate the order in which to apply fonts if they aren't available.
- Sets the source reference on Chart Studio Cloud for
family
. - Sets the source reference on Chart Studio Cloud for
lineposition
. - Sets the shape and color of the shadow behind text. auto places minimal shadow and applies contrast text font color. See https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow for additional options.
- Sets the source reference on Chart Studio Cloud for
shadow
. - Sets the source reference on Chart Studio Cloud for
size
. - Sets the source reference on Chart Studio Cloud for
style
. - Sets the source reference on Chart Studio Cloud for
textcase
. - Sets the source reference on Chart Studio Cloud for
variant
. - Sets the source reference on Chart Studio Cloud for
weight
. - Sets the source reference on Chart Studio Cloud for
textposition
. - Sets the source reference on Chart Studio Cloud for
text
. - Template string used for rendering the information text that appear on points. Note that this will override
textinfo
. Variables are inserted using %{variable}, for example "y: %{y}". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. Every attributes that can be specified per-point (the ones that arearrayOk: true
) are available. Finally, the template string has access to variablesinitial
,delta
,final
andlabel
. - Sets the source reference on Chart Studio Cloud for
texttemplate
. - Assign an id to this trace, Use this to provide object constancy between traces during animations and transitions.
- Sets the source reference on Chart Studio Cloud for
width
. - Sets the hover text formatting rulefor
x
using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted usingxaxis.hoverformat
. - Sets the source reference on Chart Studio Cloud for
x
. - Sets the hover text formatting rulefor
y
using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: %h for half of the year as a decimal number as well as %{n}f for fractional seconds with n digits. For example, 2016-10-13 09:15:23.456 with tickformat %H~%M~%S.%2f would display 09~15~23.46By default the values are formatted usingyaxis.hoverformat
. - Sets the source reference on Chart Studio Cloud for
y
.