imad-hl commented on code in PR #35859:
URL: https://github.com/apache/superset/pull/35859#discussion_r2682255937


##########
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js:
##########
@@ -156,18 +201,123 @@ function CountryMap(element, props) {
       );
   };
 
+  // Mouse move handler to update tooltip position
   const mousemove = function mousemove() {
     const position = d3.mouse(svg.node());
     hoverPopup
       .style('top', `${position[1] + 30}px`)
       .style('left', `${position[0]}px`);
   };
 
+  // Mouse out handler
   const mouseout = function mouseout() {
-    d3.select(this).style('fill', colorFn);
+    d3.select(this).style('fill', d => colorFn(d));
     hoverPopup.style('display', 'none');
   };
 
+  // Zoom with panning bounds
+  const zoom = d3.behavior
+    .zoom()
+    .scaleExtent([1, 4])
+    .on('zoomstart', () => {
+      svg.style('cursor', 'grabbing');
+    })
+    .on('zoom', () => {
+      const { translate, scale } = d3.event;
+      let [tx, ty] = translate;
+
+      const scaledW = width * scale;
+      const scaledH = height * scale;
+      const minX = Math.min(0, width - scaledW);
+      const maxX = 0;
+      const minY = Math.min(0, height - scaledH);
+      const maxY = 0;
+
+      tx = Math.max(Math.min(tx, maxX), minX);
+      ty = Math.max(Math.min(ty, maxY), minY);

Review Comment:
   Applied the hooks default fix ! 
   
   However, the zoom panning bounds suggestion is incorrect. The original code 
properly uses container dimensions to keep scaled content within the viewport. 
Using map dimensions causes the map to pan outside the visible area. Tested 
with Chile map and confirmed current implementation works correctly



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to