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

const ApexChart = () => {
  const [state, setState] = React.useState({
    series: [
      {
        data: [
          {
            x: 'node_modules',
            y: 428,
          },
          {
            x: 'assets',
            y: 213,
          },
          {
            x: '.git',
            y: 154,
          },
          {
            x: 'build',
            y: 96,
          },
          {
            x: 'vendor',
            y: 88,
          },
          {
            x: 'public',
            y: 61,
          },
          {
            x: 'src',
            y: 47,
          },
          {
            x: 'cache',
            y: 39,
          },
          {
            x: 'docs',
            y: 24,
          },
          {
            x: 'tests',
            y: 18,
          },
          {
            x: 'logs',
            y: 12,
          },
          {
            x: 'config',
            y: 6,
          },
        ],
      },
    ],
    options: {
      legend: {
        show: false,
      },
      chart: {
        height: 350,
        type: 'treemap',
      },
      title: {
        text: 'Disk Usage by Folder (GB)',
        align: 'center',
      },
      colors: [
        '#3B93A5',
        '#F7B844',
        '#ADD8C7',
        '#EC3C65',
        '#CDD7B6',
        '#C1F666',
        '#D43F97',
        '#1E5D8C',
        '#421243',
        '#7F94B0',
        '#EF6537',
        '#C0ADDB',
      ],
      plotOptions: {
        treemap: {
          distributed: true,
          enableShades: false,
        },
      },
    },
  })

  return (
    <div>
      <div id="chart">
        <ReactApexChart
          options={state.options}
          series={state.series}
          type="treemap"
          height={350}
        />
      </div>
    </div>
  )
}

export default ApexChart
Distributed Treemap - React Treemap Charts | ApexCharts.js | ApexCharts.js