0.3.2 • Published 3 years ago

taro-calendar-heatmap v0.3.2

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

Taro Calendar Heatmap

基于 Taro 的日历热力图,生成类似于 GitHub Contribution 统计图。

Todo

  • 展示 Tooltip
  • 点击回调以及样式
  • 适配 Dark Mode

安装与引入

安装

npm i taro-calendar-heatmap --save

引入

import CalendarHeatmap from 'taro-calendar-heatmap';
// 引入样式
import 'taro-calendar-heatmap/dist/index.css';

组件使用

const data = [
  { date: '2021-3-24', count: 6 },
  { date: '2021-3-25', count: 1 },
  { date: '2021-3-26', count: 4 },
  { date: '2021-3-27', count: 5 },
  { date: '2021-3-28', count: 7 },
];
<CalendarHeatMap data={data} showMonthLabel showWeekLabel theme="github" />;

API

参数说明类型默认值
spacing方块的间隙number1
squareWidth方块的宽度number14
radius方块的弧度number3
colorRange颜色范围,第一个颜色值为方块未填充的颜色string[][]
theme日历主题github | purple | volcano | blue | orangegithub
startDate开始时间,可以传时间字符串、Date、时间戳string | Date | numberOne year ago
endDate结束时间,可以传时间字符串、Date、时间戳string | Date | numberToday
showWeekLabel是否显示周标签booleanfalse
showMonthLabel是否显示月份标签booleanfalse
firstDay每周的第一天MonSunMon
data日历数据DataProp[][]
onClick点击回调,可以在回调可以获取点击的日期时间Function(date: Date ) => {}
showTooltip点击是否显示提示booleanfalse
tooltipContent提示框内容,可以穿字符串或者组件。stringElement日期

DataProp

参数说明类型默认值
count次数,次数越多,颜色越深number0
date可以传时间字符串、Date、时间戳string | Date | numbernull

Theme

组件内置了 GitHub、酱紫、火山、极客蓝、日暮五种主题,效果如下。

theme主题名称截图
githubGitHubIMG_0460EB86E4FA-1
purple酱紫IMG_BAE84FD8F6A4-1
volcano火山IMG_2D06301BC78A-1
blue极客蓝IMG_A2F31DAC7516-1
orange日暮IMG_B861E55C242B-1