I'm trying to access children nodes of currently zoomed in cell in D3 zoomable Treemap. Specifically, I'd like to replace the href
attribute in nested image
nodes.
Is there a way of selecting just the children elements of the current node inside function zoomed(d){}
, ideally without filtering the whole treemap, i.e. by utilising node.children
property?
Something like this:
function zoomed(d) {
// get children nodes data
const currentChildren = d.children; // [Zh, Zh, Zh] - ok
// select all children of current node
// and select their image nodes
// then update href attribute
d3.select(this)
.select(d => d.children)
.selectAll("image")
.attr("href", d => "/img/" + d.data.image);
}
Each cell structure is this:
g
rect
clipPath
svg
image
question from:
https://stackoverflow.com/questions/66066789/in-d3-how-can-i-select-specific-children-elements-of-current-node-in-zoomable-t 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…