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: [576, 168, 42, 34],
    options: {
      chart: {
        type: 'unit',
        height: 470,
        animations: {
          enabled: true,
          speed: 900,
        },
      },
      labels: ['Communications', 'Earth observation', 'Science', 'Crewed'],
      colors: ['#008FFB', '#00B8A9', '#FFAB00', '#FF7A45'],
      plotOptions: {
        unit: {
          layout: 'custom',
          // One of the shapes in apexcharts/unit-shapes.
          positions: 'rocket',
          transition: 'flow',
          clusterLabels: {
            show: false,
          },
        },
      },
      legend: {
        position: 'bottom',
      },
    },
  })

  return (
    <div>
      <div className="wrap">
        <h1>820 payloads to orbit, one dot each</h1>
        <p>
          Nose, hull, porthole and swept fins. The fins are separate subpaths
          that overlap the hull and the porthole is one wound the other way, so
          a shape with thin extremities and a hole in it is still a single
          packing pass.
        </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 = 1 payload</p>
      </div>
    </div>
  )
}

export default ApexChart
Rocket Payloads - React Unit Charts | ApexCharts.js | ApexCharts.js