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: [2880, 840, 210, 170],
    options: {
      chart: {
        type: 'unit',
        height: 470,
        animations: {
          enabled: true,
          speed: 900,
        },
      },
      labels: ['Secure', 'Monitored', 'At risk', 'Critical'],
      colors: ['#00A96E', '#008FFB', '#FFAB00', '#FF4560'],
      plotOptions: {
        unit: {
          layout: 'custom',
          // One of the shapes in apexcharts/unit-shapes.
          positions: 'shield',
          transition: 'flow',
          unitValue: 5,
          clusterLabels: {
            show: false,
          },
        },
      },
      legend: {
        position: 'bottom',
      },
    },
  })

  return (
    <div>
      <div className="wrap">
        <h1>4,100 devices, one dot per five</h1>
        <p>
          Endpoint posture on a shield. Rows are handed out from the top, so the
          healthy majority fills the broad shoulders and the critical tail lands
          in the point, where a few dots are impossible to miss.
        </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 = 5 managed devices</p>
      </div>
    </div>
  )
}

export default ApexChart
Shield Security - React Unit Charts | ApexCharts.js | ApexCharts.js