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

const ApexChart = () => {
  const [state, setState] = React.useState({
    series: [
      {
        name: 'North',
        data: [
          {
            x: 'Q1',
            y: 503,
          },
          {
            x: 'Q2',
            y: 580,
          },
          {
            x: 'Q3',
            y: 135,
          },
        ],
      },
      {
        name: 'South',
        data: [
          {
            x: 'Q1',
            y: 733,
          },
          {
            x: 'Q2',
            y: 385,
          },
          {
            x: 'Q3',
            y: 715,
          },
        ],
      },
      {
        name: 'East',
        data: [
          {
            x: 'Q1',
            y: 255,
          },
          {
            x: 'Q2',
            y: 211,
          },
          {
            x: 'Q3',
            y: 441,
          },
        ],
      },
      {
        name: 'West',
        data: [
          {
            x: 'Q1',
            y: 428,
          },
          {
            x: 'Q2',
            y: 749,
          },
          {
            x: 'Q3',
            y: 559,
          },
        ],
      },
    ],
    options: {
      chart: {
        height: 350,
        width: 600,
        type: 'line',
      },
      plotOptions: {
        line: {
          isSlopeChart: true,
        },
      },
      title: {
        text: 'Regional Sales Rank by Quarter',
      },
      tooltip: {
        followCursor: true,
        intersect: false,
        shared: true,
      },
      dataLabels: {
        background: {
          enabled: true,
        },
        formatter(val, opts) {
          const seriesName = opts.w.config.series[opts.seriesIndex].name
          return val !== null ? seriesName : ''
        },
      },
      yaxis: {
        show: true,
        labels: {
          show: true,
        },
      },
      xaxis: {
        position: 'bottom',
      },
      legend: {
        show: true,
        position: 'top',
        horizontalAlign: 'left',
      },
      stroke: {
        width: [2, 3, 4, 2],
        dashArray: [0, 0, 5, 2],
        curve: 'smooth',
      },
    },
  })

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

export default ApexChart
Slope Multi Group - React Slope Charts | ApexCharts.js | ApexCharts.js