A d3.js heatmap representing time series data. Inspired by Github's contribution chart
![]()
gh-pages branch [in progress]| Property | Usage | Default | Required |
|---|---|---|---|
| data | Chart data | none | yes |
| selector | DOM selector to attach the chart to | body | 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 | 'contributions' | no |
| legendEnabled | Option to render a legend | true | no |
| onClick | callback function on day click events (see example below) | null | no |
1: Add d3.js and moment.js
2: Include calendar-heatmap.js and calendar-heatmap.css
<link rel="stylesheet" type="text/css" href="https://github.com/DKirwan/calendar-heatmap/raw/0.4.1/path/tocalendar-heatmap.css">
<script src="https://github.com/DKirwan/calendar-heatmap/raw/0.4.1/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
...are very welcome!
$ claude mcp add calendar-heatmap \
-- python -m otcore.mcp_server <graph>