Skip to content

Commit

Permalink
Use pointer-events instead of display property to turn off filtering …
Browse files Browse the repository at this point in the history
…by labels
  • Loading branch information
mtraynham committed Oct 14, 2015
1 parent 579cec4 commit 430d711
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/bubble-mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ dc.bubbleMixin = function (_chart) {
return shouldLabel(d) ? 1 : 0;
};

var labelDisplay = function (d) {
return shouldLabel(d) ? 'block' : 'none';
var labelPointerEvent = function (d) {
return shouldLabel(d) ? 'all' : 'none';
};

_chart._doRenderLabel = function (bubbleGEnter) {
Expand All @@ -120,29 +120,20 @@ dc.bubbleMixin = function (_chart) {

label
.attr('opacity', 0)
.text(labelFunction)
.style('display', 'none');
.attr('pointer-events', labelPointerEvent)
.text(labelFunction);
dc.transition(label, _chart.transitionDuration())
.attr('opacity', labelOpacity)
.call(dc.afterTransition, label.style.bind(label, 'display', labelDisplay));
.attr('opacity', labelOpacity);
}
};

_chart.doUpdateLabels = function (bubbleGEnter) {
if (_chart.renderLabel()) {
var labels = bubbleGEnter.selectAll('text')
.text(labelFunction)
.style('display', function (d) {
// On update, we can't fade in if it's hidden...
var current = d3.select(this).style('display');
if (current === 'none' && shouldLabel(d)) {
return 'block';
}
return current;
});
.attr('pointer-events', labelPointerEvent)
.text(labelFunction);
dc.transition(labels, _chart.transitionDuration())
.attr('opacity', labelOpacity)
.call(dc.afterTransition, labels.style.bind(labels, 'display', labelDisplay));
.attr('opacity', labelOpacity);
}
};

Expand Down

0 comments on commit 430d711

Please sign in to comment.