Github Style Calendar Heatmap In jQuery

Github Style Calendar Heatmap In jQuery
File Size: 8.08 KB
Views Total: 327
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   

Just another jQuery plugin that dynamically renders a calendar heatmap (year view) to visualize time series data (like activities, contribution) similar to Github contribution graph.

Note: This is the upgraded version of the jQuery Contribution Graph plugin that supports multiple activities per day.

See also:

How to use it:

1. Add the Calendar Yearview with Blocks plugin's files to the web page.

<link href="/path/to/css/calendar_yearview_blocks.css" rel="stylesheet" />
<script src="/path/to/cdn/jquery.slim.min.js"></script>
<script src="/path/to/js/calendar_yearview_blocks.js"></script>

2. Create a container to hold the calendar heatmap.

<div id="example"></div>

3. Add activities to the calendar heatmap.

const mydata = {
      "2020-09-01":  {
        "items": ["banana", "apple"]
      }, 
      "2020-08-05": {
        "items": ["apple"]
      }, 
      "2020-07-01": {
        "items": ["banana"]
      }, 
      "2020-06-03": {
        "items": ["banana", "apple", "orange"]
      }
      // more activities here
}

4. Initialize the plugin to render the activities as blocks in the calendar heatmap.

$('#example').calendar_yearview_blocks({
  data: myData
});

5. Customize the block colors.

$('#example').calendar_yearview_blocks({
  data: myData,
  colors: {
    'default': '#eeeeee', 
    'apple': 'green',
    'banana': 'yellow',
    'orange': 'orange',
    'pear': 'lightgreen'
  }
});

6. Customize/localize the day/month names.

$('#example').calendar_yearview_blocks({
  data: myData,
  month_names: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun', 'jul', 'aug', 'sept', 'okt', 'nov', 'dec'],
  day_names: ['ma', 'wo', 'vr', 'zo']
});

7. Determine whether the week start on Monday. Default: true.

$('#example').calendar_yearview_blocks({
  start_monday: false // start on Sunday
});

8. Determine whether to display the tooltip only when there are activities to be shown. Default: false.

$('#example').calendar_yearview_blocks({
  always_show_tooltip: true
});

9. Determine whether to highlight today's date. Default: false.

$('#example').calendar_yearview_blocks({
  stylize_today: true
});

This awesome jQuery plugin is developed by SaeX. For more Advanced Usages, please check the demo page or visit the official website.