@@ -14,17 +14,25 @@ var isUnifiedHover = require('./helpers').isUnifiedHover;
14
14
module . exports = function handleHoverLabelDefaults ( contIn , contOut , coerce , opts ) {
15
15
opts = opts || { } ;
16
16
17
+ function inheritFontAttr ( attr ) {
18
+ if ( ! opts . font [ attr ] ) {
19
+ if ( contIn . legend && contIn . legend . font && contIn . legend . font [ attr ] ) {
20
+ opts . font [ attr ] = contIn . legend . font [ attr ] ;
21
+ } else if ( contIn . font && contIn . font [ attr ] ) {
22
+ opts . font [ attr ] = contIn . font [ attr ] ;
23
+ }
24
+ }
25
+ }
26
+
17
27
// In unified hover, inherit from legend if available
18
28
if ( contIn && isUnifiedHover ( contIn . hovermode ) ) {
19
- if ( ! opts . bgcolor && contIn . legend ) opts . bgcolor = contIn . legend . bgcolor ;
20
- if ( ! opts . bordercolor && contIn . legend ) opts . bordercolor = contIn . legend . bordercolor ;
21
- // Merge in decreasing order of importance layout.font, layout.legend.font and hoverlabel.font
22
-
23
- var l = contIn . legend ;
24
29
if ( ! opts . font ) opts . font = { } ;
25
- if ( ! opts . font . size ) opts . font . size = l && l . size ? l . size : contIn . font . size ;
26
- if ( ! opts . font . family ) opts . font . family = l && l . family ? l . family : contIn . font . family ;
27
- if ( ! opts . font . color ) opts . font . color = l && l . color ? l . color : contIn . font . color ;
30
+ inheritFontAttr ( 'size' ) ;
31
+ inheritFontAttr ( 'family' ) ;
32
+ inheritFontAttr ( 'color' ) ;
33
+
34
+ if ( ! opts . bgcolor && contIn . legend && contIn . legend . bgcolor ) opts . bgcolor = contIn . legend . bgcolor ;
35
+ if ( ! opts . bordercolor && contIn . legend && contIn . legend . bordercolor ) opts . bordercolor = contIn . legend . bordercolor ;
28
36
}
29
37
30
38
coerce ( 'hoverlabel.bgcolor' , opts . bgcolor ) ;
0 commit comments