Skip to content

Commit 7140374

Browse files
committed
update closest logic
1 parent edf2125 commit 7140374

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

tensorboard/webapp/metrics/views/card_renderer/scalar_card_component.ts

+2-7
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ import {TimeSelectionView} from './utils';
5858

5959
type ScalarTooltipDatum = TooltipDatum<
6060
ScalarCardSeriesMetadata & {
61-
distToCursor: number;
6261
closest: boolean;
6362
}
6463
>;
@@ -172,10 +171,6 @@ export class ScalarCardComponent<Downloader> {
172171
metadata: {
173172
...datum.metadata,
174173
closest: false,
175-
distToCursor: Math.hypot(
176-
datum.point.x - cursorLocationInDataCoord.x,
177-
datum.point.y - cursorLocationInDataCoord.y
178-
),
179174
distToCursorPixels: Math.hypot(
180175
datum.pixelLocation.x - cursorLocation.x,
181176
datum.pixelLocation.y - cursorLocation.y
@@ -189,8 +184,8 @@ export class ScalarCardComponent<Downloader> {
189184
let minDist = Infinity;
190185
let minIndex = 0;
191186
for (let index = 0; index < scalarTooltipData.length; index++) {
192-
if (minDist > scalarTooltipData[index].metadata.distToCursor) {
193-
minDist = scalarTooltipData[index].metadata.distToCursor;
187+
if (minDist > scalarTooltipData[index].metadata.distToCursorPixels) {
188+
minDist = scalarTooltipData[index].metadata.distToCursorPixels;
194189
minIndex = index;
195190
}
196191
}

0 commit comments

Comments
 (0)