From fcf540c670413039a5f6c8d3cc5988e63dc2e3b5 Mon Sep 17 00:00:00 2001 From: Gordon Woodhull Date: Fri, 22 Jul 2016 15:11:55 -0400 Subject: [PATCH] highlight slices on hovering labels and paths for #1167 replaces 0a35ef61, which would have disabled clicking on exterior labels --- src/pie-chart.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/pie-chart.js b/src/pie-chart.js index bd47acb91..b30648855 100644 --- a/src/pie-chart.js +++ b/src/pie-chart.js @@ -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 @@ -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); @@ -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();