@@ -26,6 +26,8 @@ var assertElemRightTo = customAssertions.assertElemRightTo;
26
26
var assertElemTopsAligned = customAssertions . assertElemTopsAligned ;
27
27
var assertElemInside = customAssertions . assertElemInside ;
28
28
29
+ var groupTitlesMock = require ( '@mocks/legendgroup-titles' ) ;
30
+
29
31
function touch ( path , options ) {
30
32
var len = path . length ;
31
33
Lib . clearThrottle ( ) ;
@@ -4547,17 +4549,6 @@ describe('hovermode: (x|y)unified', function() {
4547
4549
} ) ;
4548
4550
}
4549
4551
4550
- function assertFont ( fontFamily , fontSize , fontColor ) {
4551
- var hover = getHoverLabel ( ) ;
4552
- var text = hover . select ( 'text.legendtext' ) ;
4553
- var node = text . node ( ) ;
4554
-
4555
- var textStyle = window . getComputedStyle ( node ) ;
4556
- expect ( textStyle . fontFamily . split ( ',' ) [ 0 ] ) . toBe ( fontFamily , 'wrong font family' ) ;
4557
- expect ( textStyle . fontSize ) . toBe ( fontSize , 'wrong font size' ) ;
4558
- expect ( textStyle . fill ) . toBe ( fontColor , 'wrong font color' ) ;
4559
- }
4560
-
4561
4552
it ( 'set smart defaults for spikeline in x unified' , function ( done ) {
4562
4553
Plotly . newPlot ( gd , [ { y : [ 4 , 6 , 5 ] } ] , { 'hovermode' : 'x unified' , 'xaxis' : { 'color' : 'red' } } )
4563
4554
. then ( function ( gd ) {
@@ -6011,6 +6002,17 @@ describe('hovermode: (x|y)unified', function() {
6011
6002
} ) ;
6012
6003
6013
6004
it ( 'should use hoverlabel.font or legend.font or layout.font' , function ( done ) {
6005
+ function assertFont ( fontFamily , fontSize , fontColor ) {
6006
+ var hover = getHoverLabel ( ) ;
6007
+ var text = hover . select ( 'text.legendtext' ) ;
6008
+ var node = text . node ( ) ;
6009
+
6010
+ var textStyle = window . getComputedStyle ( node ) ;
6011
+ expect ( textStyle . fontFamily . split ( ',' ) [ 0 ] ) . toBe ( fontFamily , 'wrong font family' ) ;
6012
+ expect ( textStyle . fontSize ) . toBe ( fontSize , 'wrong font size' ) ;
6013
+ expect ( textStyle . fill ) . toBe ( fontColor , 'wrong font color' ) ;
6014
+ }
6015
+
6014
6016
var mockCopy = Lib . extendDeep ( { } , mock ) ;
6015
6017
6016
6018
// Set layout.font
@@ -6078,6 +6080,38 @@ describe('hovermode: (x|y)unified', function() {
6078
6080
. then ( done , done . fail ) ;
6079
6081
} ) ;
6080
6082
6083
+ it ( 'should use hoverlabel.font for group titles as well as traces' , function ( done ) {
6084
+ function assertFont ( fontFamily , fontSize , fontColor ) {
6085
+ var hover = getHoverLabel ( ) ;
6086
+ var traces = hover . selectAll ( 'g.traces' ) ;
6087
+
6088
+ traces . each ( function ( ) {
6089
+ var e = d3Select ( this ) ;
6090
+ var text = e . select ( 'text.legendtext' ) ;
6091
+ var node = text . node ( ) ;
6092
+
6093
+ var textStyle = window . getComputedStyle ( node ) ;
6094
+ expect ( textStyle . fontFamily . split ( ',' ) [ 0 ] ) . toBe ( fontFamily , 'wrong font family' ) ;
6095
+ expect ( textStyle . fontSize ) . toBe ( fontSize , 'wrong font size' ) ;
6096
+ expect ( textStyle . fill ) . toBe ( fontColor , 'wrong font color' ) ;
6097
+ } ) ;
6098
+ }
6099
+
6100
+ var mockCopy = Lib . extendDeep ( { } , groupTitlesMock ) ;
6101
+
6102
+ mockCopy . layout . hoverlabel = {
6103
+ font : { size : 20 , family : 'Mono' , color : 'rgb(255, 127, 0)' }
6104
+ } ;
6105
+
6106
+ Plotly . newPlot ( gd , mockCopy )
6107
+ . then ( function ( gd ) {
6108
+ _hover ( gd , { xval : 0 } ) ;
6109
+
6110
+ assertFont ( 'Mono' , '20px' , 'rgb(255, 127, 0)' ) ;
6111
+ } )
6112
+ . then ( done , done . fail ) ;
6113
+ } ) ;
6114
+
6081
6115
it ( 'should work with hovertemplate' , function ( done ) {
6082
6116
var mockCopy = Lib . extendDeep ( { } , mock ) ;
6083
6117
mockCopy . data [ 0 ] . hovertemplate = 'hovertemplate: %{y:0.2f}' ;
0 commit comments