bito-code-review[bot] commented on code in PR #35859:
URL: https://github.com/apache/superset/pull/35859#discussion_r2645416175
##########
superset-frontend/plugins/legacy-plugin-chart-country-map/src/CountryMap.js:
##########
@@ -179,34 +322,37 @@ function CountryMap(element, props) {
.translate([width / 2, height / 2]);
path.projection(projection);
- // Compute scale that fits container.
const bounds = path.bounds(mapData);
const hscale = (scale * width) / (bounds[1][0] - bounds[0][0]);
const vscale = (scale * height) / (bounds[1][1] - bounds[0][1]);
- const newScale = hscale < vscale ? hscale : vscale;
+ const newScale = Math.min(hscale, vscale);
- // Compute bounds and offset using the updated scale.
projection.scale(newScale);
const newBounds = path.bounds(mapData);
projection.translate([
width - (newBounds[0][0] + newBounds[1][0]) / 2,
height - (newBounds[0][1] + newBounds[1][1]) / 2,
]);
- // Draw each province as a path
- mapLayer
- .selectAll('path')
- .data(features)
+ const sel = mapLayer.selectAll('path.region').data(features);
+
+ sel
.enter()
.append('path')
- .attr('d', path)
.attr('class', 'region')
.attr('vector-effect', 'non-scaling-stroke')
+ .attr('d', path)
.style('fill', colorFn)
.on('mouseenter', mouseenter)
.on('mousemove', mousemove)
.on('mouseout', mouseout)
- .on('click', clicked);
+ .on('contextmenu', handleContextMenu)
+ .on('click', handleClick );
+
+ mapLayer.selectAll('path.region').attr('d', path).style('fill', colorFn);
+ sel.exit().remove();
+
+ highlightSelectedRegion();
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>D3 Update Selection Missing Events</b></div>
<div id="fix">
Event handlers are set only on enter(), so existing map regions lose
mouse/click interactivity when features update. Add .on() calls to the update
line.
</div>
</div>
<small><i>Code Review Run #9a6202</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]