Skip to content

Commit 69311fc

Browse files
author
Jon M. Mease
committed
Implement plotly_unhover events
1 parent 30ca2ec commit 69311fc

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

src/traces/parcats/parcats.js

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,7 @@ function performPlot(parcatsModels, graphDiv, layout, svg) {
311311
// categorySelection.select('rect.catrect')
312312
categorySelection.selectAll('rect.bandrect')
313313
.on('mouseover', mouseoverCategoryBand)
314-
.on('mouseout', function(d) {
315-
mouseoutCategory(d.parcatsViewModel);
316-
});
314+
.on('mouseout', mouseoutCategory);
317315

318316
// Remove unused categories
319317
categorySelection.exit().remove();
@@ -481,6 +479,12 @@ function mouseoutPath(d) {
481479

482480
// Restore path order
483481
d.parcatsViewModel.pathSelection.sort(compareRawColor);
482+
483+
// Emit unhover event
484+
if(d.parcatsViewModel.hoverinfoItems.indexOf('skip') === -1) {
485+
var points = buildPointsArrayForPath(d);
486+
d.parcatsViewModel.graphDiv.emit('plotly_unhover', {points: points, event: d3.event});
487+
}
484488
}
485489
}
486490

@@ -930,11 +934,14 @@ function mouseoverCategoryBand(bandViewModel) {
930934
}
931935
}
932936

937+
933938
/**
934-
* Handle dimension mouseout
935-
* @param {ParcatsViewModel} parcatsViewModel
939+
* Handle dimension mouseover
940+
* @param {CategoryBandViewModel} bandViewModel
936941
*/
937-
function mouseoutCategory(parcatsViewModel) {
942+
function mouseoutCategory(bandViewModel) {
943+
944+
var parcatsViewModel = bandViewModel.parcatsViewModel;
938945

939946
if(!parcatsViewModel.dragDimension) {
940947
// We're not dragging anything
@@ -949,6 +956,21 @@ function mouseoutCategory(parcatsViewModel) {
949956

950957
// Restore path order
951958
parcatsViewModel.pathSelection.sort(compareRawColor);
959+
960+
// Emit unhover event
961+
if(parcatsViewModel.hoverinfoItems.indexOf('skip') === -1) {
962+
963+
var hovermode = bandViewModel.parcatsViewModel.hovermode;
964+
var bandElement = this;
965+
966+
// Handle style and events
967+
if (hovermode === 'color') {
968+
emitPointsEventColorHovermode(bandElement, 'plotly_unhover', d3.event);
969+
} else {
970+
console.log('mouseoutCategory: ' + hovermode);
971+
emitPointsEventCategoryHovermode(bandElement, 'plotly_unhover', d3.event);
972+
}
973+
}
952974
}
953975
}
954976

0 commit comments

Comments
 (0)