Navigation

v2.1.0
Comparison

Waterfall chart

How a figure became another, as steps up and down from the first to the last.

On this page

A waterfall shows how one figure became another: cash at the start of a period, what came in and what went out, and cash at its end. The first value stands on the baseline, each one after it is a step from where the last left off, and a hairline carries each bar's end to the next so the eye follows the count. A step up and a step down are told apart by a status ink and by the sign written with their value.

Waterfall chart

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Cash</h3>    <p class="card-description">Thousands of dollars, January to June</p>  </div>  <figure class="chart" id="cash" style="--chart-height: 13rem"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('cash'), {  type: 'waterfall',  total: 'June',  values: true,  label: 'Cash from January to June, in thousands of dollars',  labels: ['January', 'Sales', 'Refunds', 'Payroll', 'Grants', 'Rent'],  series: [{ name: 'Cash', values: [420, 310, -64, -280, 90, -110] }]})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto">  <div className="card-header">    <h3 className="card-title">Cash</h3>    <p className="card-description">Thousands of dollars, January to June</p>  </div>  <Chart    id="cash"    style={{ '--chart-height': '13rem' } as React.CSSProperties}    type="waterfall"    total="June"    values    label="Cash from January to June, in thousands of dollars"    labels={['January', 'Sales', 'Refunds', 'Payroll', 'Grants', 'Rent']}    series={[{ name: 'Cash', values: [420, 310, -64, -280, 90, -110] }]}  /></div>
<script>  import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Cash</h3>    <p class="card-description">Thousands of dollars, January to June</p>  </div>  <Chart    id="cash"    style="--chart-height: 13rem"    type="waterfall"    total="June"    values    label="Cash from January to June, in thousands of dollars"    labels={['January', 'Sales', 'Refunds', 'Payroll', 'Grants', 'Rent']}    series={[{ name: 'Cash', values: [420, 310, -64, -280, 90, -110] }]}  /></div>
<script setup>import Chart from './ui/Chart.vue'</script><template>  <div class="card max-w(560) mx-auto">    <div class="card-header">      <h3 class="card-title">Cash</h3>      <p class="card-description">Thousands of dollars, January to June</p>    </div>    <Chart      id="cash"      style="--chart-height: 13rem"      type="waterfall"      total="June"      values      label="Cash from January to June, in thousands of dollars"      :labels="['January', 'Sales', 'Refunds', 'Payroll', 'Grants', 'Rent']"      :series="[{ name: 'Cash', values: [420, 310, -64, -280, 90, -110] }]"    />  </div></template>

total names a closing bar that stands on the baseline at the sum. Without it the chart ends on its last step, which suits a list of changes with no figure to arrive at. values: true writes each step over its bar with its sign; the readout adds where the count stood after it.

#Up, down and the status inks

A waterfall is the one form whose marks take the status inks: a step up is drawn in the success ink and a step down in the danger ink, as a stat's change is. The ink is never alone: the sign is written with every value, in the readout and in each point's name. Where up is not good, such as costs, say so in the chart's label and its title.

#Options

OptionDefault
labelnoneWhat the chart shows and in what unit: the plot's accessible name
labels[]The names along the scale, around a radar or over a heatmap's columns
series[]Each with a name and what its form reads: values, a value, points, ranges or children; optionally a category, a type, low and high, and a ring's max
totalnoneA waterfall's closing bar: its name
min, max, ticksfit, 4The ends of the scale and about how many steps mark it; xMin, xMax and xTicks for a scatter's scale across
format, tickFormatthe locale'sHow a value and a tick are written; xFormat for a scatter's scale across
dots, valuesfalseMark every point of a line; write every bar's value
currentnoneThe index of the point marked aria-current

The readout, the keys, the legend, the colors and the scale are the same in every form: Chart holds them, with every option, class and custom property.