@@ -26,6 +26,8 @@ var assertElemRightTo = customAssertions.assertElemRightTo;
2626var assertElemTopsAligned = customAssertions . assertElemTopsAligned ;
2727var assertElemInside = customAssertions . assertElemInside ;
2828
29+ var groupTitlesMock = require ( '@mocks/legendgroup-titles' ) ;
30+
2931function touch ( path , options ) {
3032 var len = path . length ;
3133 Lib . clearThrottle ( ) ;
@@ -4547,17 +4549,6 @@ describe('hovermode: (x|y)unified', function() {
45474549 } ) ;
45484550 }
45494551
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-
45614552 it ( 'set smart defaults for spikeline in x unified' , function ( done ) {
45624553 Plotly . newPlot ( gd , [ { y : [ 4 , 6 , 5 ] } ] , { 'hovermode' : 'x unified' , 'xaxis' : { 'color' : 'red' } } )
45634554 . then ( function ( gd ) {
@@ -6011,6 +6002,17 @@ describe('hovermode: (x|y)unified', function() {
60116002 } ) ;
60126003
60136004 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+
60146016 var mockCopy = Lib . extendDeep ( { } , mock ) ;
60156017
60166018 // Set layout.font
@@ -6078,6 +6080,38 @@ describe('hovermode: (x|y)unified', function() {
60786080 . then ( done , done . fail ) ;
60796081 } ) ;
60806082
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+
60816115 it ( 'should work with hovertemplate' , function ( done ) {
60826116 var mockCopy = Lib . extendDeep ( { } , mock ) ;
60836117 mockCopy . data [ 0 ] . hovertemplate = 'hovertemplate: %{y:0.2f}' ;
0 commit comments