import React from 'react'
import ReactApexChart from 'react-apexcharts'
import './styles.css'
const ApexChart = () => {
const [state, setState] = React.useState({
series: [
{
name: 'Fantasy',
data: [44, 55, 41, 37, 22, 43, 21],
},
{
name: 'Mystery',
data: [53, 32, 33, 52, 13, 43, 32],
},
{
name: 'Romance',
data: [12, 17, 11, 9, 15, 11, 20],
},
{
name: 'Sci-Fi',
data: [9, 7, 5, 8, 6, 9, 4],
},
{
name: 'Thriller',
data: [25, 12, 19, 32, 25, 24, 10],
},
],
options: {
chart: {
type: 'bar',
height: 350,
stacked: true,
},
plotOptions: {
bar: {
horizontal: true,
dataLabels: {
total: {
enabled: true,
offsetX: 0,
style: {
fontSize: '13px',
fontWeight: 900,
},
},
},
},
},
stroke: {
width: 1,
colors: ['#fff'],
},
title: {
text: 'Book Sales by Genre',
},
xaxis: {
categories: [2019, 2020, 2021, 2022, 2023, 2024, 2025],
labels: {
formatter: function (val) {
return val + 'K'
},
},
},
yaxis: {
title: {
text: undefined,
},
},
tooltip: {
y: {
formatter: function (val) {
return val + 'K'
},
},
},
fill: {
opacity: 1,
},
legend: {
position: 'top',
horizontalAlign: 'left',
offsetX: 40,
},
},
})
return (
<div>
<div id="chart">
<ReactApexChart
options={state.options}
series={state.series}
type="bar"
height={350}
/>
</div>
</div>
)
}
export default ApexChart