@@ -796,9 +796,7 @@ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
796796 var winningPoint = hoverData [ 0 ] ;
797797 // discard other points
798798 if ( multipleHoverPoints [ winningPoint . trace . type ] ) {
799- hoverData = hoverData . filter ( function ( d ) {
800- return d . trace . index === winningPoint . trace . index ;
801- } ) ;
799+ hoverData = hoverData . filter ( ( d ) => d . trace . index === winningPoint . trace . index ) ;
802800 } else {
803801 hoverData = [ winningPoint ] ;
804802 }
@@ -851,8 +849,7 @@ function _hover(gd, evt, subplot, noHoverEvent, eventTarget) {
851849
852850 // pull out just the data that's useful to
853851 // other people and send it to the event
854- for ( itemnum = 0 ; itemnum < hoverData . length ; itemnum ++ ) {
855- var pt = hoverData [ itemnum ] ;
852+ for ( const pt of hoverData ) {
856853 var eventData = helpers . makeEventData ( pt , pt . trace , pt . cd ) ;
857854
858855 if ( pt . hovertemplate !== false ) {
@@ -1237,9 +1234,7 @@ function createHoverText(hoverData, opts) {
12371234 if ( helpers . isUnifiedHover ( hovermode ) ) {
12381235 // Delete leftover hover labels from other hovermodes
12391236 container . selectAll ( 'g.hovertext' ) . remove ( ) ;
1240- var groupedHoverData = hoverData . filter ( function ( data ) {
1241- return data . hoverinfo !== 'none' ;
1242- } ) ;
1237+ const groupedHoverData = hoverData . filter ( ( data ) => data . hoverinfo !== 'none' ) ;
12431238 // Return early if nothing is hovered on
12441239 if ( groupedHoverData . length === 0 ) return [ ] ;
12451240
@@ -1253,12 +1248,12 @@ function createHoverText(hoverData, opts) {
12531248
12541249 var mainText = ! unifiedhovertitleText
12551250 ? t0
1256- : Lib . hovertemplateString (
1257- unifiedhovertitleText ,
1258- { } ,
1259- fullLayout . _d3locale ,
1260- hovermode === 'x unified' ? { xa : item0 . xa , x : item0 . xVal } : { ya : item0 . ya , y : item0 . yVal }
1261- ) ;
1251+ : Lib . hovertemplateString ( {
1252+ args : hovermode === 'x unified' ? { xa : item0 . xa , x : item0 . xVal } : { ya : item0 . ya , y : item0 . yVal } ,
1253+ d3locale : fullLayout . _d3locale ,
1254+ fallback : item0 . trace . hovertemplatefallback ,
1255+ string : unifiedhovertitleText
1256+ } ) ;
12621257
12631258 var mockLayoutIn = {
12641259 showlegend : true ,
@@ -1624,9 +1619,7 @@ function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) {
16241619 if ( d . nameOverride !== undefined ) d . name = d . nameOverride ;
16251620
16261621 if ( d . name ) {
1627- if ( d . trace . _meta ) {
1628- d . name = Lib . templateString ( d . name , d . trace . _meta ) ;
1629- }
1622+ if ( d . trace . _meta ) d . name = Lib . templateString ( d . name , d . trace . _meta ) ;
16301623 name = plainText ( d . name , d . nameLength ) ;
16311624 }
16321625
@@ -1669,24 +1662,24 @@ function getHoverLabelText(d, showCommonLabel, hovermode, fullLayout, t0, g) {
16691662 }
16701663
16711664 // hovertemplate
1672- var hovertemplate = d . hovertemplate || false ;
1665+ const { hovertemplate = false } = d ;
16731666 if ( hovertemplate ) {
1674- var labels = d . hovertemplateLabels || d ;
1667+ const labels = d . hovertemplateLabels || d ;
16751668
16761669 if ( d [ h0 + 'Label' ] !== t0 ) {
16771670 labels [ h0 + 'other' ] = labels [ h0 + 'Val' ] ;
16781671 labels [ h0 + 'otherLabel' ] = labels [ h0 + 'Label' ] ;
16791672 }
16801673
1681- text = Lib . hovertemplateString (
1682- hovertemplate ,
1674+ text = Lib . hovertemplateString ( {
1675+ args : [ d . eventData [ 0 ] || { } , d . trace . _meta ] ,
1676+ d3locale : fullLayout . _d3locale ,
1677+ fallback : d . trace . hovertemplatefallback ,
16831678 labels,
1684- fullLayout . _d3locale ,
1685- d . eventData [ 0 ] || { } ,
1686- d . trace . _meta
1687- ) ;
1679+ string : hovertemplate
1680+ } ) ;
16881681
1689- text = text . replace ( EXTRA_STRING_REGEX , function ( match , extra ) {
1682+ text = text . replace ( EXTRA_STRING_REGEX , ( _ , extra ) => {
16901683 // assign name for secondary text label
16911684 name = plainText ( extra , d . nameLength ) ;
16921685 // remove from main text label
@@ -2487,12 +2480,8 @@ function getCoord(axLetter, winningPoint, fullLayout) {
24872480// Top/left hover offsets relative to graph div. As long as hover content is
24882481// a sibling of the graph div, it will be positioned correctly relative to
24892482// the offset parent, whatever that may be.
2490- function getTopOffset ( gd ) {
2491- return gd . offsetTop + gd . clientTop ;
2492- }
2493- function getLeftOffset ( gd ) {
2494- return gd . offsetLeft + gd . clientLeft ;
2495- }
2483+ const getTopOffset = ( gd ) => gd . offsetTop + gd . clientTop ;
2484+ const getLeftOffset = ( gd ) => gd . offsetLeft + gd . clientLeft ;
24962485
24972486function getBoundingClientRect ( gd , node ) {
24982487 var fullLayout = gd . _fullLayout ;
0 commit comments