@@ -163,7 +163,8 @@ export class ScalarCardComponent<Downloader> {
163
163
164
164
getCursorAwareTooltipData (
165
165
tooltipData : TooltipDatum < ScalarCardSeriesMetadata > [ ] ,
166
- cursorLoc : { x : number ; y : number }
166
+ cursorLocationInDataCoord : { x : number ; y : number } ,
167
+ cursorLocation : { x : number ; y : number }
167
168
) : ScalarTooltipDatum [ ] {
168
169
const scalarTooltipData = tooltipData . map ( ( datum ) => {
169
170
return {
@@ -172,8 +173,20 @@ export class ScalarCardComponent<Downloader> {
172
173
...datum . metadata ,
173
174
closest : false ,
174
175
distSqToCursor : Math . hypot (
175
- datum . point . x - cursorLoc . x ,
176
- datum . point . y - cursorLoc . y
176
+ datum . point . x - cursorLocationInDataCoord . x ,
177
+ datum . point . y - cursorLocationInDataCoord . y
178
+ ) ,
179
+ distSqToCursorPixels : Math . hypot (
180
+ datum . point . x - cursorLocation . x ,
181
+ datum . point . y - cursorLocation . y
182
+ ) ,
183
+ distSqToCursorX : Math . hypot (
184
+ datum . point . x - cursorLocationInDataCoord . x ,
185
+ 0
186
+ ) ,
187
+ distSqToCursorY : Math . hypot (
188
+ 0 ,
189
+ datum . point . y - cursorLocationInDataCoord . y
177
190
) ,
178
191
} ,
179
192
} ;
@@ -201,6 +214,20 @@ export class ScalarCardComponent<Downloader> {
201
214
return scalarTooltipData . sort ( ( a , b ) => {
202
215
return a . metadata . distSqToCursor - b . metadata . distSqToCursor ;
203
216
} ) ;
217
+ case TooltipSort . NEAREST_PIXEL :
218
+ return scalarTooltipData . sort ( ( a , b ) => {
219
+ return (
220
+ a . metadata . distSqToCursorPixels - b . metadata . distSqToCursorPixels
221
+ ) ;
222
+ } ) ;
223
+ case TooltipSort . NEAREST_X :
224
+ return scalarTooltipData . sort ( ( a , b ) => {
225
+ return a . metadata . distSqToCursorX - b . metadata . distSqToCursorX ;
226
+ } ) ;
227
+ case TooltipSort . NEAREST_Y :
228
+ return scalarTooltipData . sort ( ( a , b ) => {
229
+ return a . metadata . distSqToCursorY - b . metadata . distSqToCursorY ;
230
+ } ) ;
204
231
case TooltipSort . DEFAULT :
205
232
case TooltipSort . ALPHABETICAL :
206
233
return scalarTooltipData . sort ( ( a , b ) => {
0 commit comments