Skip to content

Commit

Permalink
Fix #34
Browse files Browse the repository at this point in the history
In  v3 the entering elements were implicitly included in the update selection so there was no need for .merge
  • Loading branch information
cy6erskunk committed Apr 8, 2018
1 parent a902000 commit c402f3f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/calendar-heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function calendarHeatmap() {
Less: 'Less',
More: 'More'
};
var v = Number(d3.version.split('.')[0]);

// setters and getters
chart.data = function (value) {
Expand Down Expand Up @@ -125,7 +126,7 @@ function calendarHeatmap() {
dayRects = svg.selectAll('.day-cell')
.data(dateRange); // array of days for the last yr

dayRects.enter().append('rect')
var enterSelection = dayRects.enter().append('rect')
.attr('class', 'day-cell')
.attr('width', SQUARE_LENGTH)
.attr('height', SQUARE_LENGTH)
Expand All @@ -140,14 +141,14 @@ function calendarHeatmap() {
});

if (typeof onClick === 'function') {
dayRects.on('click', function (d) {
(v === 3 ? enterSelection : enterSelection.merge(dayRects)).on('click', function(d) {
var count = countForDate(d);
onClick({ date: d, count: count});
});
}

if (chart.tooltipEnabled()) {
dayRects.on('mouseover', function (d, i) {
(v === 3 ? enterSelection : enterSelection.merge(dayRects)).on('mouseover', function(d, i) {
tooltip = d3.select(chart.selector())
.append('div')
.attr('class', 'day-cell-tooltip')
Expand Down

0 comments on commit c402f3f

Please sign in to comment.