Skip to content

added hoverlabel namelength option #1818

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

Closed
wants to merge 3 commits into from
Closed
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
7 changes: 7 additions & 0 deletions src/components/fx/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ module.exports = {
family: extendFlat({}, fontAttrs.family, { arrayOk: true }),
size: extendFlat({}, fontAttrs.size, { arrayOk: true }),
color: extendFlat({}, fontAttrs.color, { arrayOk: true })
},
namelength: {
valType: 'number',
min: 0,
dflt: 15,
role: 'style',
description: 'Sets the length (in number of characters) of the hover labels for this trace'
}
}
};
2 changes: 1 addition & 1 deletion src/components/fx/hover.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ function createHoverText(hoverData, opts, gd) {
// strip out our pseudo-html elements from d.name (if it exists at all)
name = svgTextUtils.plainText(d.name || '');

if(name.length > 15) name = name.substr(0, 12) + '...';
if(name.length > commonLabelOpts.namelength && commonLabelOpts.namelength > 0) name = name.substr(0, commonLabelOpts.namelength - 3) + '...';
}

// used by other modules (initially just ternary) that
Expand Down
1 change: 1 addition & 0 deletions src/components/fx/hoverlabel_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts

coerce('hoverlabel.bgcolor', opts.bgcolor);
coerce('hoverlabel.bordercolor', opts.bordercolor);
coerce('hoverlabel.namelength', opts.namelength);
Lib.coerceFont(coerce, 'hoverlabel.font', opts.font);
};
7 changes: 7 additions & 0 deletions src/components/fx/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ module.exports = {
dflt: constants.HOVERFONTSIZE
}),
color: extendFlat({}, fontAttrs.color)
},
namelength: {
valType: 'number',
min: 0,
dflt: 15,
role: 'style',
description: 'Sets the length (in number of characters) of the hover labels for this trace'
}
}
};