Skip to content
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

Support hovertemplate on hoveron: fills #6121

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion src/traces/scatter/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
dfltHoverOn.push('fills');
}
coerce('hoveron', dfltHoverOn.join('+') || 'points');
if(traceOut.hoveron !== 'fills') coerce('hovertemplate');
coerce('hovertemplate', false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could oossibly use

Suggested change
coerce('hovertemplate', false);
coerce('hovertemplate');

so that hovertemplate defaults to blank string.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we keep the initial if statement and just add a condition for lines mode?

if(traceOut.hoveron !== 'fills' || traceOut.mode === 'lines') coerce('hovertemplate');

var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {axis: 'y'});
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {axis: 'x', inherit: 'y'});
Expand Down
7 changes: 5 additions & 2 deletions src/traces/scatter/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
else if(Color.opacity((trace.line || {}).color)) {
color = trace.line.color;
}

var hovertemplate = false;
fredricj marked this conversation as resolved.
Show resolved Hide resolved
if(trace.mode === 'lines') {
hovertemplate = trace.hovertemplate;
}
Lib.extendFlat(pointData, {
// never let a 2D override 1D type as closest point
// also: no spikeDistance, it's not allowed for fills
Expand All @@ -194,7 +197,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
y0: yAvg,
y1: yAvg,
color: color,
hovertemplate: false
hovertemplate: hovertemplate,
});

delete pointData.index;
Expand Down