<template>
  <div>
    <div id="chart">
      <apexchart
        type="waterfall"
        height="400"
        :options="chartOptions"
        :series="series"
      ></apexchart>
    </div>
  </div>
</template>

<script>
import VueApexCharts from 'vue-apexcharts'

export default {
  components: {
    apexchart: VueApexCharts,
  },
  data: function () {
    return {
      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,
            },
          ],
        },
      ],
      chartOptions: {
        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
          },
        },
      },
    }
  },
}
</script>

<style>
#chart {
  max-width: 650px;
  margin: 35px auto;
}
</style>