Skip to content

Commit

Permalink
support both d3 v3 & v4 methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cy6erskunk committed Mar 7, 2018
1 parent 7d1b971 commit ba76099
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/calendar-heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ function calendarHeatmap() {

d3.select(chart.selector()).selectAll('svg.calendar-heatmap').remove(); // remove the existing chart, if it exists

var dateRange = d3.time.days(yearAgo, now); // generates an array of date objects within the specified range
var monthRange = d3.time.months(moment(yearAgo).startOf('month').toDate(), now); // it ignores the first month if the 1st date is after the start of the month
var dateRange = ((d3.time && d3.time.days) || d3.timeDays)(yearAgo, now); // generates an array of date objects within the specified range
var monthRange = ((d3.time && d3.time.months) || d3.timeMonths)(moment(yearAgo).startOf('month').toDate(), now); // it ignores the first month if the 1st date is after the start of the month
var firstDate = moment(dateRange[0]);
if (chart.data().length == 0) {
max = 0;
Expand All @@ -104,7 +104,7 @@ function calendarHeatmap() {
}

// color range
var color = d3.scale.linear()
var color = ((d3.scale && d3.scale.linear) || d3.scaleLinear)()
.range(chart.colorRange())
.domain([0, max]);

Expand Down Expand Up @@ -198,7 +198,6 @@ function calendarHeatmap() {
.data(monthRange)
.enter().append('text')
.attr('class', 'month-name')
.style()
.text(function (d) {
return locale.months[d.getMonth()];
})
Expand Down

0 comments on commit ba76099

Please sign in to comment.