I'm attempting to implement a mouseover effect that increases the opacity of elements that are not being hovered on.
My SVG map consists of various regions, with the current function applying an opacity of 0.8 to the selected region.
My goal is to reverse this so that the remaining regions receive the opacity of 0.8.
Below is the snippet of my code:
function render(svg) {
d3.select("body").node().append(svg.documentElement)
data.forEach(d => {
d3.selectAll(`g[aria-label="${d.id}"]`)
.datum(data)
.selectAll('path')
.style("fill", colorScale(d.value))
.on('mouseover', function() {
d3.selectAll(`g[aria-label="${d.id}"]`)
.filter(function(e) {
return e.id !== d.id
})
.style('opacity', 0.8)
})
.on('mouseout', function() {
d3.selectAll(`g[aria-label="${d.id}"]`)
.style('opacity', 1)
})
})
I initially added e.id !==d.id
to achieve this effect, but it yielded the opposite result.
Link to my fiddle: jsfiddle