Skip to content

Commit

Permalink
Keep tooltip in div with position relative on selector
Browse files Browse the repository at this point in the history
Before, the (absolute) tooltip was not contained within the selector
div. Test by setting ` style="margin-top: 200px”` on `<div
class="container">` in `example/index.html`. Now fixed by setting
position: relative on selector.
Side effect was that tooltip came closer to selected cell, so updated
position.
  • Loading branch information
peterdesmet committed Jan 20, 2017
1 parent 391d81d commit 3df2d65
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/calendar-heatmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ function calendarHeatmap() {

function drawChart() {
var svg = d3.select(chart.selector())
.style('position', 'relative')
.append('svg')
.attr('width', width)
.attr('class', 'calendar-heatmap')
Expand Down Expand Up @@ -122,7 +123,7 @@ function calendarHeatmap() {
.html(tooltipHTMLForDate(d))
.style('left', function () { return Math.floor(i / 7) * SQUARE_LENGTH + 'px'; })
.style('top', function () {
return formatWeekday(d.getDay()) * (SQUARE_LENGTH + SQUARE_PADDING) + MONTH_LABEL_PADDING * 3 + 'px';
return formatWeekday(d.getDay()) * (SQUARE_LENGTH + SQUARE_PADDING) + MONTH_LABEL_PADDING * 2 + 'px';
});
})
.on('mouseout', function (d, i) {
Expand Down

0 comments on commit 3df2d65

Please sign in to comment.