From 7f1fef00b5987869167657121485fe4094172a43 Mon Sep 17 00:00:00 2001 From: Tarek Quao Date: Thu, 5 Dec 2024 11:11:29 +0000 Subject: [PATCH 1/3] shows the right tooltip for the correct cell the cursor hovers over Signed-off-by: Tarek Quao --- .../src/ts/tooltip/nearbyTip.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts b/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts index 39a2657137..868d48117b 100644 --- a/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts +++ b/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts @@ -147,10 +147,16 @@ export default (): NearbyTip => { ) return null; - return Math.sqrt( - Math.pow((xScale(v[xValueName]) as number) - pos.x, 2) + - Math.pow(scale(v[yValueName]) - pos.y, 2) - ); + const xDist = (xScale(v[xValueName]) as number) - pos.x; + const yDist = scale(v[yValueName]) - pos.y; + + + if (xDist <= 0 && yDist <= 0) { + return Math.sqrt( + Math.pow(xDist, 2) + + Math.pow(yDist, 2) + ); + } }; }; From 7ebb0767cea240f7ac3449f0da8a3835a4b73e20 Mon Sep 17 00:00:00 2001 From: Tarek Quao Date: Thu, 5 Dec 2024 12:31:55 +0000 Subject: [PATCH 2/3] run prettier on nearbyTp.ts file Signed-off-by: Tarek Quao --- .../src/ts/tooltip/nearbyTip.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts b/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts index 868d48117b..6de085f3db 100644 --- a/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts +++ b/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts @@ -101,7 +101,7 @@ export default (): NearbyTip => { raiseEvent( selection.node(), tooltipData[0], - base.settings() + base.settings(), ); } }) @@ -121,14 +121,14 @@ export default (): NearbyTip => { .attr("class", "nearbyTip") .merge(tips) .attr("r", (d) => - size ? scale_factor * Math.sqrt(size(d.size)) : 10 + size ? scale_factor * Math.sqrt(size(d.size)) : 10, ) .attr( "transform", (d) => `translate(${xScale(d[xValueName])},${useYScale( - d[yValueName] - )})` + d[yValueName], + )})`, ) .style("stroke", "none") .style("fill", (d) => color && d.key && withOpacity(color(d.key))); @@ -150,12 +150,8 @@ export default (): NearbyTip => { const xDist = (xScale(v[xValueName]) as number) - pos.x; const yDist = scale(v[yValueName]) - pos.y; - if (xDist <= 0 && yDist <= 0) { - return Math.sqrt( - Math.pow(xDist, 2) + - Math.pow(yDist, 2) - ); + return Math.sqrt(Math.pow(xDist, 2) + Math.pow(yDist, 2)); } }; }; @@ -170,7 +166,7 @@ export default (): NearbyTip => { const best2 = findBestFromData( altDataWithScale.data, dist2, - Math.min + Math.min, ); return dist1(best1) <= dist2(best2) ? { data: best1, scale: yScale } From 5f9f7a3186c3978eee4e3740e687b026c3b58cea Mon Sep 17 00:00:00 2001 From: Tarek Quao Date: Mon, 9 Dec 2024 11:29:40 +0000 Subject: [PATCH 3/3] run prettier to update formatting Signed-off-by: Tarek Quao --- .../src/ts/tooltip/nearbyTip.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts b/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts index 6de085f3db..982df5465b 100644 --- a/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts +++ b/packages/perspective-viewer-d3fc/src/ts/tooltip/nearbyTip.ts @@ -101,7 +101,7 @@ export default (): NearbyTip => { raiseEvent( selection.node(), tooltipData[0], - base.settings(), + base.settings() ); } }) @@ -121,14 +121,14 @@ export default (): NearbyTip => { .attr("class", "nearbyTip") .merge(tips) .attr("r", (d) => - size ? scale_factor * Math.sqrt(size(d.size)) : 10, + size ? scale_factor * Math.sqrt(size(d.size)) : 10 ) .attr( "transform", (d) => `translate(${xScale(d[xValueName])},${useYScale( - d[yValueName], - )})`, + d[yValueName] + )})` ) .style("stroke", "none") .style("fill", (d) => color && d.key && withOpacity(color(d.key))); @@ -166,7 +166,7 @@ export default (): NearbyTip => { const best2 = findBestFromData( altDataWithScale.data, dist2, - Math.min, + Math.min ); return dist1(best1) <= dist2(best2) ? { data: best1, scale: yScale }