calendar-heatmap

A d3 heatmap for representing time series data similar to github's contribution chart

Github星跟蹤圖

This project is not actively maintained

D3 Calendar Heatmap

A d3.js heatmap representing time series data. Inspired by Github's contribution chart

Reusable D3.js Calendar Heatmap chart

Configuration, Property, Usage, Default, Required, :-------------, :-------------, :-----:, :-----:, data, Chart data, none, yes, selector, DOM selector to attach the chart to, body, no, max, Maximum count, max found in data, no, startDate, Date to start heatmap at, 1 year ago, no, colorRange, Minimum and maximum chart gradient colors, ['#D8E6E7', '#218380'], no, tooltipEnabled, Option to render a tooltip, true, no, tooltipUnit, Unit to render on the tooltip, can be object for pluralization control, 'contributions', no, legendEnabled, Option to render a legend, true, no, onClick, callback function on day click events (see example below), null, no, locale, Object to translate every word used, except for tooltipUnit, see below, no, ### Default locale object

{
    months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
    days: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
    No: 'No',
    on: 'on',
    Less: 'Less',
    More: 'More'
}

Dependencies

Usage

1: Add d3.js and moment.js

2: Include calendar-heatmap.js and calendar-heatmap.css
<link rel="stylesheet" type="text/css" href="path/tocalendar-heatmap.css">
<script src="path/to/calendar-heatmap.js"></script>

3: Format the data so each array item has a date and count property.
As long as new Date() can parse the date string it's ok. Note - there all data should be rolled up into daily bucket granularity.

4: Configure the chart and render it

// chart data example
var chartData = [{
  date: valid Javascript date object,
  count: Number
}];
var chart1 = calendarHeatmap()
              .data(chartData)
              .selector('#chart-one')
              .colorRange(['#D8E6E7', '#218380'])
              .tooltipEnabled(true)
              .onClick(function (data) {
                console.log('onClick callback. Data:', data);
              });
chart1();  // render the chart

control unit pluralization

var chart1 = calendarHeatmap()
              .data(chartData)
              .tooltipUnit(
                [
                  {min: 0, unit: 'contribution'},
                  {min: 1, max: 1, unit: 'contribution'},
                  {min: 2, max: 'Infinity', unit: 'contributions'}
                ]
              );
chart1();  // render the chart

Pull Requests and issues

...are very welcome!

主要指標

概覽
名稱與所有者DKirwan/calendar-heatmap
主編程語言JavaScript
編程語言HTML (語言數: 3)
平台
許可證MIT License
所有者活动
創建於2016-02-16 20:54:30
推送於2020-08-09 18:04:29
最后一次提交2019-03-12 22:48:22
發布數12
最新版本名稱0.4.1 (發布於 2016-08-20 09:20:31)
第一版名稱0.1.0 (發布於 2016-03-13 22:26:01)
用户参与
星數2k
關注者數37
派生數140
提交數88
已啟用問題?
問題數0
打開的問題數0
拉請求數16
打開的拉請求數5
關閉的拉請求數1
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?