import React from 'react'
import ReactApexChart from 'react-apexcharts'
import './styles.css'

// This demo also loads: https://cdn.jsdelivr.net/npm/apexcharts/dist/unit-shapes.js

const ApexChart = () => {
  const [state, setState] = React.useState({
    series: [3400, 900, 300, 200],
    options: {
      chart: {
        type: 'unit',
        height: 470,
        animations: {
          enabled: true,
          speed: 900,
        },
      },
      labels: ['Passed first time', 'Passed after a fix', 'Waived', 'Failed'],
      colors: ['#00A96E', '#00B8A9', '#FFAB00', '#FF4560'],
      plotOptions: {
        unit: {
          layout: 'custom',
          // A stroke shape from apexcharts/unit-shapes.
          positions: 'check',
          transition: 'flow',
          unitValue: 6,
          clusterLabels: {
            // Outer labels: each band is named in the margin with a leader line to its
            // own dots, so the crowd reads without a legend.
            external: {
              show: true,
            },
          },
        },
      },
      legend: {
        show: false,
      },
    },
  })

  return (
    <div>
      <div className="wrap">
        <h1>4,800 compliance checks, one dot per 6</h1>
        <p>
          A checkmark has no interior, only a line and a thickness, so the dots
          pack a stroked centreline rather than an outline. That is a different
          region behind the same packer: the shape is three points and a width,
          instead of both sides of both arms with a mitred corner drawn by hand.
        </p>

        <div className="chart-wrap">
          <div id="chart">
            <ReactApexChart
              options={state.options}
              series={state.series}
              type="unit"
              height={470}
            />
          </div>
        </div>

        <p className="note">1 dot = 6 checks</p>
      </div>
    </div>
  )
}

export default ApexChart
Compliance Checks - React Unit Charts | ApexCharts.js | ApexCharts.js