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: [576000, 168000, 42000, 34000],
options: {
chart: {
type: 'unit',
height: 470,
animations: {
enabled: true,
speed: 900,
},
},
labels: ['Owner occupied', 'Private rent', 'Social rent', 'Vacant'],
colors: ['#E07B39', '#2E86AB', '#00A96E', '#7B8794'],
plotOptions: {
unit: {
layout: 'custom',
// One of the shapes in apexcharts/unit-shapes.
positions: 'house',
transition: 'flow',
unitValue: 1000,
clusterLabels: {
show: false,
},
},
},
legend: {
position: 'bottom',
},
},
})
return (
<div>
<div className="wrap">
<h1>820,000 homes, one dot per thousand</h1>
<p>
Roof, walls, a door and two windows. The openings are subpaths wound
the other way, so the layout skips them while it packs: the door is
dots that are missing rather than anything drawn over the top.
</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 = 1,000 homes</p>
</div>
</div>
)
}
export default ApexChart