@@ -3,9 +3,10 @@ import {getSource} from "../channel.js";
33import { create } from "../context.js" ;
44import { defined } from "../defined.js" ;
55import { formatDefault } from "../format.js" ;
6+ import { pointerPosition } from "../interactions/pointer.js" ;
67import { Mark } from "../mark.js" ;
78import { maybeAnchor , maybeFrameAnchor , maybeTuple , number , string } from "../options.js" ;
8- import { applyDirectStyles , applyFrameAnchor , applyIndirectStyles , applyTransform , impliedString } from "../style.js" ;
9+ import { applyDirectStyles , applyIndirectStyles , applyTransform , impliedString } from "../style.js" ;
910import { inferTickFormat } from "./axis.js" ;
1011import { applyIndirectTextStyles , defaultWidth , ellipsis , monospaceWidth } from "./text.js" ;
1112import { cut , clipper , splitter , maybeTextOverflow } from "./text.js" ;
@@ -92,12 +93,10 @@ export class Tip extends Mark {
9293 // unspecified, we fallback to the frame anchor. We also need to know the
9394 // facet offsets to detect when the tip would draw outside the plot, and
9495 // thus we need to change the orientation.
95- const { x : X , y : Y , x1 : X1 , y1 : Y1 , x2 : X2 , y2 : Y2 } = channels ;
96- const [ cx , cy ] = applyFrameAnchor ( this , dimensions ) ;
96+ const { x1 : X1 , y1 : Y1 , x2 : X2 , y2 : Y2 , x : X = X1 ?? X2 , y : Y = Y1 ?? Y2 } = channels ;
9797 const ox = fx ? fx ( index . fx ) - marginLeft : 0 ;
9898 const oy = fy ? fy ( index . fy ) - marginTop : 0 ;
99- const px = X2 ? ( i ) => ( X1 [ i ] + X2 [ i ] ) / 2 : X ? ( i ) => X [ i ] : ( ) => cx ;
100- const py = Y2 ? ( i ) => ( Y1 [ i ] + Y2 [ i ] ) / 2 : Y ? ( i ) => Y [ i ] : ( ) => cy ;
99+ const [ px , py ] = pointerPosition ( mark , channels , dimensions ) ;
101100
102101 // Resolve the text metric implementation. We may need an ellipsis for text
103102 // truncation, so we optimistically compute the ellipsis width.
@@ -142,7 +141,7 @@ export class Tip extends Mark {
142141 const g = create ( "svg:g" , context )
143142 . call ( applyIndirectStyles , this , dimensions , context )
144143 . call ( applyIndirectTextStyles , this )
145- . call ( applyTransform , this , { x : ( X || X2 ) && x , y : ( Y || Y2 ) && y } )
144+ . call ( applyTransform , this , { x : X && x , y : Y && y } )
146145 . call ( ( g ) =>
147146 g
148147 . selectAll ( )
0 commit comments