8000 Hover on fills by alexcjohnson · Pull Request #673 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Hover on fills #673

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 22, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix and test hoveron=fills for scatterternary
  • Loading branch information
alexcjohnson committed Jun 20, 2016
commit ffd56c733fbdbd48a04945656b647fe9c0007e68
1 change: 1 addition & 0 deletions src/traces/scatterternary/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ module.exports = {
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
flags: ['a', 'b', 'c', 'text', 'name']
}),
hoveron: scatterAttrs.hoveron,
_nestedModules: {
'marker.colorbar': 'Colorbar'
}
Expand Down
8 changes: 8 additions & 0 deletions src/traces/scatterternary/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
handleTextDefaults(traceIn, traceOut, layout, coerce);
}

var dfltHoverOn = '';

if(subTypes.hasMarkers(traceOut) || subTypes.hasText(traceOut)) {
coerce('marker.maxdisplayed');
dfltHoverOn = 'points';
}

coerce('fill');
Expand All @@ -92,4 +95,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}

coerce('hoverinfo', (layout._dataLength === 1) ? 'a+b+c+text' : undefined);

if(!dfltHoverOn && (traceOut.fill === 'tonext' || traceOut.fill === 'toself')) {
dfltHoverOn = 'fills';
}
coerce('hoveron', dfltHoverOn || 'points');
};
4 changes: 4 additions & 0 deletions src/traces/scatterternary/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
var scatterPointData = scatterHover(pointData, xval, yval, hovermode);
if(!scatterPointData || scatterPointData[0].index === false) return;

// if hoveron='fills', we don't show any point data so the label is
// unchanged from what scatter gives us.
if(scatterPointData[0].index === undefined) return scatterPointData;

var newPointData = scatterPointData[0],
cdi = newPointData.cd[newPointData.index];

Expand Down
13 changes: 13 additions & 0 deletions 8B52 test/jasmine/tests/hover_label_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -690,4 +690,17 @@ describe('hover on fill', function() {
return assertLabelsCorrect([155, 260], [160.325, 248.1], 'trace 0');
}).then(done);
});

it('should work for scatterternary too', function(done) {
var mock = require('@mocks/ternary_fill.json');
mock.data.forEach(function(trace) { trace.hoveron = 'fills'; });

Plotly.plot(createGraphDiv(), mock.data, mock.layout).then(function() {
return assertLabelsCorrect([245, 171], [249.7, 166], 'trace 2');
}).then(function() {
return assertLabelsCorrect([245, 226], [268.75, 265], 'trace 1');
}).then(function() {
return assertLabelsCorrect([245, 259], [249.7, 254], 'trace 0');
}).then(done);
});
});
0