bito-code-review[bot] commented on code in PR #35859:
URL: https://github.com/apache/superset/pull/35859#discussion_r2682263912
##########
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:
<!-- Bito Reply -->
The PR's zoom implementation uses container width and height for panning
bounds, ensuring the scaled map stays within the viewport. This aligns with
your explanation.
**superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js**
```
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;
```
--
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]