Waterfall

author(s): Torstein Hønsi

by Pawan Jadhav

HTML

<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>

<figure class="highcharts-figure">
    <div id="container"></div>
    <p class="highcharts-description">
        Waterfall charts are used to visualize cumulative values,
        where each data point contributes to a total. In this example,
        points showing intermediate sums are used to indicate the
        progression of the total.
    </p>
</figure>

CSS

.highcharts-figure,
.highcharts-data-table table {
    min-width: 320px;
    max-width: 700px;
    margin: 1em auto;
}

.highcharts-data-table table {
    font-family: Verdana, sans-serif;
    border-collapse: collapse;
    border: 1px solid #ebebeb;
    margin: 10px auto;
    text-align: center;
    width: 100%;
    max-width: 500px;
}

.highcharts-data-table caption {
    padding: 1em 0;
    font-size: 1.2em;
    color: #555;
}

.highcharts-data-table th {
    font-weight: 600;
    padding: 0.5em;
}

.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
    padding: 0.5em;
}

.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
    background: #f8f8f8;
}

.highcharts-data-table tr:hover {
    background: #f1f7ff;
}

JavaScript

Highcharts.chart('container', {
    chart: {
        type: 'waterfall',
        inverted: true
    },

    title: {
        text: 'Highcharts Waterfall'
    },

    xAxis: {
        type: 'category'
    },

    yAxis: {
        title: {
            text: 'USD'
        }
    },

    legend: {
        enabled: false
    },

    tooltip: {
        pointFormat: '<b>${point.y:,.2f}</b> USD'
    },

    series: [{
    	borderColor :'',
        upColor: "rgba(255,1,80,1)",
        color: "rgba(5,137,241,1)",
        data: [{
            name: 'medinc',
            y: 0.94
        }, {
            name: 'AveOccup',
            y: -0.16
        }
        , {
            name: 'population',
            y: 0.14
        }, {
            name: 'houseage',
            y: -0.13
        }, {
            name: 'latitude',
            y: 0.1
        }, {
            name: 'longitude',
            y: 0.1
        }, {
            name: 'AveRooms',
            y: -0.08
        }],
        dataLabels: {
            enabled: true,
           
        },
        pointPadding: 0
    }]
});