import React from 'react';
import { ResponsiveHeatMap } from '@nivo/heatmap';
import { AutoSizer } from 'react-virtualized';
// import AutoSizer from 'react-virtualized-auto-sizer';
// make sure parent container have a defined height when using
// responsive component, otherwise height will be 0 and
// no chart will be rendered.
// website examples showcase many properties,
// you'll often use just a few of them.
export default function NivoHeatMap({ props, data, loading, error, onClick }) {
return (
<div style={{ display: 'flex' }}>
{/* <div style={{ flex: '1 1 auto', height: '100vh' }}> */}
<div>
<AutoSizer>
{({ height, width }) =>
!loading &&
data && (
<div height={height} width={width}>
{height}, {width}
<div style={{ height: 400 }}>
<ResponsiveHeatMap
onClick={onClick}
data={data.values}
keys={data.dedicatedAreaSet}
indexBy="floor"
margin={{
top: 100,
right: 60,
bottom: 60,
left: 60,
}}
forceSquare={false}
axisTop={null}
axisBottom={{
orient: 'bottom',
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: '전용면적',
legendPosition: 'middle',
legendOffset: 36,
}}
axisLeft={{
orient: 'left',
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
legend: '층',
legendPosition: 'middle',
legendOffset: -40,
}}
colors="oranges"
cellOpacity={1}
cellShape="rect"
cellBorderColor="inherit:darker(0.4)"
labelTextColor="inherit:darker(1.8)"
// labelTextColor="#fff1fb"
defs={[
{
id: 'lines',
type: 'patternLines',
background: 'inherit',
color: 'rgba(0, 0, 0, 0.1)',
rotation: -45,
lineWidth: 4,
spacing: 7,
},
]}
fill={[
{
id: 'lines',
},
]}
animate={true}
motionStiffness={80}
motionDamping={9}
hoverTarget="cell"
cellHoverOthersOpacity={0.25}
sizeVariation={0.3}
/>
</div>
</div>
)
}
</AutoSizer>
</div>
</div>
);
}
'Web 개발 > React' 카테고리의 다른 글
[React] onKeyPress가 두번 호출 되는 현상 (0) | 2020.03.15 |
---|---|
index.js:1 Warning: Failed prop type: The prop `value` is marked as required in `HeatMapCellRect`, but its value is `undefined`. (0) | 2020.03.13 |
Error: <rect> attribute x: Expected length, "NaN" 미친듯한 에러와 팬소리에 미치다. (0) | 2020.03.11 |
[React] searchkit 사용해보자 (0) | 2020.03.02 |
[React] Route에 React Context Provider 적용하는 방법 (+소스코드) (0) | 2020.03.01 |