@@ -605,15 +605,15 @@ function _hover(gd, evt, subplot, noHoverEvent) {
605605 var result = dragElement . unhoverRaw ( gd , evt ) ;
606606 if ( hasCartesian && ( ( spikePoints . hLinePoint !== null ) || ( spikePoints . vLinePoint !== null ) ) ) {
607607 if ( spikesChanged ( oldspikepoints ) ) {
608- createSpikelines ( spikePoints , spikelineOpts ) ;
608+ createSpikelines ( gd , spikePoints , spikelineOpts ) ;
609609 }
610610 }
611611 return result ;
612612 }
613613
614614 if ( hasCartesian ) {
615615 if ( spikesChanged ( oldspikepoints ) ) {
616- createSpikelines ( spikePoints , spikelineOpts ) ;
616+ createSpikelines ( gd , spikePoints , spikelineOpts ) ;
617617 }
618618 }
619619
@@ -1396,9 +1396,10 @@ function cleanPoint(d, hovermode) {
13961396 return d ;
13971397}
13981398
1399- function createSpikelines ( closestPoints , opts ) {
1399+ function createSpikelines ( gd , closestPoints , opts ) {
14001400 var container = opts . container ;
14011401 var fullLayout = opts . fullLayout ;
1402+ var gs = fullLayout . _size ;
14021403 var evt = opts . event ;
14031404 var showY = ! ! closestPoints . hLinePoint ;
14041405 var showX = ! ! closestPoints . vLinePoint ;
@@ -1433,8 +1434,7 @@ function createSpikelines(closestPoints, opts) {
14331434 var yMode = ya . spikemode ;
14341435 var yThickness = ya . spikethickness ;
14351436 var yColor = ya . spikecolor || dfltHLineColor ;
1436- var yBB = ya . _boundingBox ;
1437- var xEdge = ( ( yBB . left + yBB . right ) / 2 ) < hLinePointX ? yBB . right : yBB . left ;
1437+ var xEdge = Axes . getPxPosition ( gd , ya ) ;
14381438 var xBase , xEndSpike ;
14391439
14401440 if ( yMode . indexOf ( 'toaxis' ) !== - 1 || yMode . indexOf ( 'across' ) !== - 1 ) {
@@ -1443,8 +1443,14 @@ function createSpikelines(closestPoints, opts) {
14431443 xEndSpike = hLinePointX ;
14441444 }
14451445 if ( yMode . indexOf ( 'across' ) !== - 1 ) {
1446- xBase = ya . _counterSpan [ 0 ] ;
1447- xEndSpike = ya . _counterSpan [ 1 ] ;
1446+ var xAcross0 = ya . _counterDomainMin ;
1447+ var xAcross1 = ya . _counterDomainMax ;
1448+ if ( ya . anchor === 'free' ) {
1449+ xAcross0 = Math . min ( xAcross0 , ya . position ) ;
1450+ xAcross1 = Math . max ( xAcross1 , ya . position ) ;
1451+ }
1452+ xBase = gs . l + xAcross0 * gs . w ;
1453+ xEndSpike = gs . l + xAcross1 * gs . w ;
14481454 }
14491455
14501456 // Foreground horizontal line (to y-axis)
@@ -1507,8 +1513,7 @@ function createSpikelines(closestPoints, opts) {
15071513 var xMode = xa . spikemode ;
15081514 var xThickness = xa . spikethickness ;
15091515 var xColor = xa . spikecolor || dfltVLineColor ;
1510- var xBB = xa . _boundingBox ;
1511- var yEdge = ( ( xBB . top + xBB . bottom ) / 2 ) < vLinePointY ? xBB . bottom : xBB . top ;
1516+ var yEdge = Axes . getPxPosition ( gd , xa ) ;
15121517 var yBase , yEndSpike ;
15131518
15141519 if ( xMode . indexOf ( 'toaxis' ) !== - 1 || xMode . indexOf ( 'across' ) !== - 1 ) {
@@ -1517,8 +1522,14 @@ function createSpikelines(closestPoints, opts) {
15171522 yEndSpike = vLinePointY ;
15181523 }
15191524 if ( xMode . indexOf ( 'across' ) !== - 1 ) {
1520- yBase = xa . _counterSpan [ 0 ] ;
1521- yEndSpike = xa . _counterSpan [ 1 ] ;
1525+ var yAcross0 = xa . _counterDomainMin ;
1526+ var yAcross1 = xa . _counterDomainMax ;
1527+ if ( xa . anchor === 'free' ) {
1528+ yAcross0 = Math . min ( yAcross0 , xa . position ) ;
1529+ yAcross1 = Math . max ( yAcross1 , xa . position ) ;
1530+ }
1531+ yBase = gs . t + ( 1 - yAcross1 ) * gs . h ;
1532+ yEndSpike = gs . t + ( 1 - yAcross0 ) * gs . h ;
15221533 }
15231534
15241535 // Foreground vertical line (to x-axis)
0 commit comments