Skip to content

Commit c76ebc2

Browse files
committed
added hoverlabel namelength option
1 parent e4c1c8c commit c76ebc2

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

src/components/fx/attributes.js

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ module.exports = {
3333
family: extendFlat({}, fontAttrs.family, { arrayOk: true }),
3434
size: extendFlat({}, fontAttrs.size, { arrayOk: true }),
3535
color: extendFlat({}, fontAttrs.color, { arrayOk: true })
36+
},
37+
namelength: {
38+
valType: 'number',
39+
min: 0,
40+
dflt: 15,
41+
role: 'style',
42+
description: 'Sets the length (in number of characters) of the hover labels for this trace'
3643
}
3744
}
3845
};

src/components/fx/hover.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ function createHoverText(hoverData, opts, gd) {
689689
// strip out our pseudo-html elements from d.name (if it exists at all)
690690
name = svgTextUtils.plainText(d.name || '');
691691

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

695695
// used by other modules (initially just ternary) that

src/components/fx/hoverlabel_defaults.js

+1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ module.exports = function handleHoverLabelDefaults(contIn, contOut, coerce, opts
1515

1616
coerce('hoverlabel.bgcolor', opts.bgcolor);
1717
coerce('hoverlabel.bordercolor', opts.bordercolor);
18+
coerce('hoverlabel.namelength', opts.namelength);
1819
Lib.coerceFont(coerce, 'hoverlabel.font', opts.font);
1920
};

src/components/fx/layout_attributes.js

+7
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ module.exports = {
5555
dflt: constants.HOVERFONTSIZE
5656
}),
5757
color: extendFlat({}, fontAttrs.color)
58+
},
59+
namelength: {
60+
valType: 'number',
61+
min: 0,
62+
dflt: 15,
63+
role: 'style',
64+
description: 'Sets the length (in number of characters) of the hover labels for this trace'
5865
}
5966
}
6067
};

0 commit comments

Comments
 (0)