HeatMap 日历热图
React component create calendar heatmap to visualize time series data, a la github contribution graph.
Install
npm install @uiw/react-heat-map --save
Basic Usage
import ReactDOM from 'react-dom';
import HeatMap from '@uiw/react-heat-map';
const Demo = () => {
const value = [
{ date: '2016/01/11', count:2, content:['一条消息来了!','一条消息来了!'] },
{ date: '2016/04/11', count:2, content:['一条消息来了!'] },
{ date: '2016/05/01', count:5, content:['需要显示的数据'] },
{ date: '2016/05/02', count:5, content:['空的没有消息'] },
{ date: '2016/05/04', count:11, content:['些放弃的人会这样想'] },
];
return (
<div>
<HeatMap value={value} startDate={new Date('2016/01/01')} />
</div>
)
};
ReactDOM.render(<Demo />, _mount_);
Props
参数 | 说明 | 类型 | 默认值 |
---|
value | Data to be displayed, required | Array | [] |
rectSize | Grid size | number | 11 |
startDate | Start date | Date | new Date() |
endDate | End date | Date | - |
space | Interval between grid sizes | number | 2 |
rectProps | Grid node attribute settings | React.SVGProps<SVGRectElement> | 2 |
weekLables | Week display | string[] | ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] |
monthLables | Month display | string[] | ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] |
panelColors | Backgroud color of active colors | Record<number, string> | { 0: '#EBEDF0', 8: '#7BC96F', 4: '#C6E48B', 12: '#239A3B', 32: '#196127' } |
renderRect | Single block re-render | () => React.ReactNode | - |
Development
development
Runs the project in development mode.
npm run watch
npm run start
production
Builds the app for production to the build folder.
npm run build
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
License
Licensed under the MIT License.