Horizontal Waterfall in JavaScript

Using ApexCharts with JavaScript

This Horizontal Waterfall example uses ApexCharts.js directly in JavaScript, with no wrapper component.

Install it with npm install apexcharts, then mount the chart with new ApexCharts(element, options).render().

JavaScript installation guide
var options = {
  series: [
    {
      name: 'Headcount',
      data: [
        {
          x: 'Opening',
          y: 412,
        },
        {
          x: 'Graduate intake',
          y: 68,
        },
        {
          x: 'Lateral hires',
          y: 41,
        },
        {
          x: 'Voluntary exits',
          y: -57,
        },
        {
          x: 'Restructuring',
          y: -34,
        },
        {
          x: 'Closing',
          isTotal: true,
        },
      ],
    },
  ],
  chart: {
    type: 'waterfall',
    height: 400,
  },
  plotOptions: {
    bar: {
      horizontal: true,
    },
  },
  title: {
    text: 'What moved headcount this year',
    align: 'left',
  },
  xaxis: {
    labels: {
      formatter: function (val) {
        return Math.round(val)
      },
    },
  },
  dataLabels: {
    formatter: function (val) {
      return (val > 0 ? '+' : '') + val
    },
  },
}

var chart = new ApexCharts(document.querySelector('#chart'), options)
chart.render()