Skip to content

Commit

Permalink
highlight slices on hovering labels and paths
Browse files Browse the repository at this point in the history
for #1167
replaces 0a35ef6, which would have disabled clicking on exterior labels
  • Loading branch information
gordonwoodhull committed Jul 28, 2016
1 parent 806be9f commit fcf540c
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/pie-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,11 @@ dc.pieChart = function (parent, chartGroup) {
.attr('text-anchor', 'middle');
}

function highlightSlice (i, whether) {
_chart.select('g.pie-slice._' + i)
.classed('highlight', whether);
}

function createLabels (labels, pieData, arc) {
if (_chart.renderLabel()) {
var labelsEnter = labels
Expand All @@ -198,7 +203,13 @@ dc.pieChart = function (parent, chartGroup) {
}
return classes;
})
.on('click', onClick);
.on('click', onClick)
.on('mouseover', function (d, i) {
highlightSlice(i, true);
})
.on('mouseout', function (d, i) {
highlightSlice(i, false);
});
positionLabels(labelsEnter, arc);
if (_externalLabelRadius && _drawPaths) {
updateLabelPaths(pieData, arc);
Expand All @@ -215,6 +226,13 @@ dc.pieChart = function (parent, chartGroup) {
.append('polyline')
.attr('class', function (d, i) {
return 'pie-path _' + i + ' ' + _sliceCssClass;
})
.on('click', onClick)
.on('mouseover', function (d, i) {
highlightSlice(i, true);
})
.on('mouseout', function (d, i) {
highlightSlice(i, false);
});

polyline.exit().remove();
Expand Down

0 comments on commit fcf540c

Please sign in to comment.