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: [360, 840, 1280, 480],
    options: {
      chart: {
        type: 'unit',
        height: 470,
        animations: {
          enabled: true,
          speed: 900,
        },
      },
      labels: ['Superstore', 'Supermarket', 'Convenience', 'Franchise'],
      colors: ['#1565C0', '#00A6A0', '#F2994A', '#7B8794'],
      plotOptions: {
        unit: {
          layout: 'custom',
          // One of the shapes in apexcharts/unit-shapes.
          positions: 'pin',
          transition: 'flow',
          unitValue: 2,
          clusterLabels: {
            show: false,
          },
        },
      },
      legend: {
        position: 'bottom',
      },
    },
  })

  return (
    <div>
      <div className="wrap">
        <h1>1,480 stores, one dot per 2</h1>
        <p>
          A map pin, bore and all. This is the only geography shape besides the
          globe, and deliberately so: country and region outlines need a real
          projection and real boundary data, which ApexMaps supplies through
          this same layout seam.
        </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 = 2 stores</p>
      </div>
    </div>
  )
}

export default ApexChart
Store Locations - React Unit Charts | ApexCharts.js | ApexCharts.js