function hover(g, svg) {
const tooltip = new Tooltip();
g.style("cursor", "pointer")
.on("touchstart", (event) => event.preventDefault())
.on("pointerenter", function (event, f) {
if (!volume.has(iso.get(f.id))) return;
tooltip.position(...d3.pointer(event));
tooltip.show(
f.properties.name,
tooltipKeyValue(
tooltipKey.toUpperCase(),
format(volume.get(iso.get(f.id))),
f
)
);
d3.select(this).transition().attr("opacity", 0.7);
})
.on("pointermove", function (event) {
let [x, y] = tooltipOffset(tooltip, d3.pointer(event), width, height);
tooltip.position(x, y);
this.releasePointerCapture(event.pointerId);
})
.on("pointerout", function () {
tooltip.hide();
d3.select(this).transition().attr("opacity", 1);
});
svg.append(() => tooltip.node);
}