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: [900000, 400000, 240000, 60000],
options: {
chart: {
type: 'unit',
height: 470,
animations: {
enabled: true,
speed: 900,
},
},
labels: ['Wifi', '5G', '4G', 'Wired'],
colors: ['#008FFB', '#00B8A9', '#F2994A', '#7B8794'],
plotOptions: {
unit: {
layout: 'custom',
// A stroke shape from apexcharts/unit-shapes.
positions: 'wifi',
transition: 'flow',
unitValue: 2000,
clusterLabels: {
// Outer labels: each band is named in the margin with a leader line to its
// own dots, so the crowd reads without a legend.
external: {
show: true,
},
},
},
},
legend: {
show: false,
},
},
})
return (
<div>
<div className="wrap">
<h1>1.6 million sessions, one dot per 2,000</h1>
<p>
Three arcs and a dot, as one stroked centreline. The gaps between the
arcs are the constraint rather than the arcs themselves: pack too few
dots and neighbouring bands merge into a solid fan, which is what this
shape's minimum count protects. The dot is a zero-length segment,
which the stroke resolves to a single disc.
</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,000 sessions</p>
</div>
</div>
)
}
export default ApexChart