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

const ApexChart = () => {
  const [state, setState] = React.useState({
    series: [
      {
        name: 'Profit',
        type: 'column',
        data: [5, 12, -8, 14, -3, 9, -2, 6],
      },
      {
        name: 'Units Sold',
        type: 'column',
        data: [1.2, 2.1, 1.8, 2.7, 2.0, 2.4, 1.9, 2.6],
      },
      {
        name: 'Index',
        type: 'line',
        data: [25, 27, 26, 29, 28, 29, 30, 30],
      },
    ],
    options: {
      chart: {
        height: 350,
        type: 'line',
        stacked: false,
      },
      stroke: {
        width: [0, 0, 4],
      },
      title: {
        text: 'Multiple Y-Axes With Aligned Zero',
        align: 'left',
      },
      xaxis: {
        categories: ['Q1', 'Q2', 'Q3', 'Q4', 'Q5', 'Q6', 'Q7', 'Q8'],
      },
      yaxis: [
        {
          seriesName: 'Profit',
          alignZero: true,
          axisTicks: { show: true },
          axisBorder: { show: true, color: '#008FFB' },
          labels: { style: { colors: '#008FFB' } },
          title: { text: 'Profit (mixed +/-)', style: { color: '#008FFB' } },
        },
        {
          seriesName: 'Units Sold',
          alignZero: true,
          opposite: true,
          axisTicks: { show: true },
          axisBorder: { show: true, color: '#00E396' },
          labels: { style: { colors: '#00E396' } },
          title: { text: 'Units (positive only)', style: { color: '#00E396' } },
        },
        {
          seriesName: 'Index',
          alignZero: true,
          opposite: true,
          axisTicks: { show: true },
          axisBorder: { show: true, color: '#FEB019' },
          labels: { style: { colors: '#FEB019' } },
          title: { text: 'Index', style: { color: '#FEB019' } },
        },
      ],
      tooltip: { shared: true, intersect: false },
      legend: { horizontalAlign: 'left' },
    },
  })

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

export default ApexChart
Multiple Y-Axes (Aligned Zero) - React Mixed / Combo Charts | ApexCharts.js | ApexCharts.js