@@ -14,17 +14,25 @@ var isUnifiedHover = require('./helpers').isUnifiedHover;
1414module . exports = function handleHoverLabelDefaults ( contIn , contOut , coerce , opts ) {
1515 opts = opts || { } ;
1616
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+
1727 // In unified hover, inherit from legend if available
1828 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 ;
2429 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 ;
2836 }
2937
3038 coerce ( 'hoverlabel.bgcolor' , opts . bgcolor ) ;
0 commit comments