Skip to content

Commit 763c044

Browse files
author
matt
committed
add changes for 1.3.0
1 parent ec4cf91 commit 763c044

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,6 @@ Take a look at the <a href="https://github.com/madams1/calendar_heatmap/wiki/Opt
8181

8282
## browser support
8383
**calendar_heatmap** is tested to work in the latest stable releases of Chrome, Firefox, and Opera
84+
85+
## dev
86+
do `npm run bundle` to create `calendar_heatmap.bundle.js` from `index.js`

calendar_heatmap.bundle.js

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ calendar_heatmap.create = function(opts) {
5757
stroke_color: opts.stroke_color ? opts.stroke_color : "#fff",
5858
discrete_scale: opts.discrete_scale ? opts.discrete_scale : false,
5959
num_colors: opts.num_colors ? opts.num_colors : null,
60+
on_click: opts.on_click ? opts.on_click : null,
6061
//// labels/legend
6162
title: opts.title ? opts.title : "",
6263
title_size: opts.title_size ? opts.title_size : 18,
@@ -129,6 +130,7 @@ calendar_heatmap.create = function(opts) {
129130
d.dow = options.sunday_start ?
130131
d.day.weekday() :
131132
d.day.isoWeekday() - 1;
133+
d.formatted_date = d.day.format("dddd MMM DD, YYYY");
132134

133135
// at the start of every week, count a new week and new week within current month
134136
if (d.dow === 0) {
@@ -217,6 +219,11 @@ calendar_heatmap.create = function(opts) {
217219
.range(palette);
218220
}
219221

222+
// add color to data
223+
_.map(options.data, function(d) {
224+
d.fill_color = d[options.fill_var] ? color_scale(d[options.fill_var]) : options.missing_color;
225+
});
226+
220227
// margins and sizes
221228
var margin = {
222229
top: options.margin_top,
@@ -582,7 +589,7 @@ calendar_heatmap.create = function(opts) {
582589
.attr("fill", "#eee");
583590

584591
this_tile.tt_group.append("text")
585-
.text(d.day.format("dddd MMM DD, YYYY"))
592+
.text(d.formatted_date)
586593
.style("font-size", "13px")
587594
.attr("text-anchor", "middle")
588595
.attr("x", options.tooltip_width/2)
@@ -639,6 +646,11 @@ calendar_heatmap.create = function(opts) {
639646
this_tile.tt_group.remove();
640647
});
641648

649+
// click
650+
if (options.on_click) {
651+
tiles.on("click", options.on_click);
652+
}
653+
642654
// return tick labels to default
643655
tile_group.on("mouseleave", function() {
644656
d3.selectAll(y_ticks)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "calendar_heatmap",
3-
"version": "1.2.1",
3+
"version": "1.3.0",
44
"description": "flexible D3 calendar heatmaps a la GitHub contribution calendars",
55
"main": "index.js",
66
"scripts": {

0 commit comments

Comments
 (0)