I am currently dealing with a JSON file that has some nesting:
{
"name": "1370",
"children": [
{
"name": "Position X",
"value": -1
},
{...}
]
"matches": [
{
"certainty": 100,
"match": {
"name": "1370",
"children": [
{
"name": "Position X",
"value": -1
},
{...}
]
}
}
]
}
My goal is to represent this data using an adapted Collapsible Tree. I aim to show the "match" and "certainty" when hovering over the respective node. To achieve this, I have been following the simple tooltip example.
Currently, my code looks like this:
var nodeEnter = node.enter().append("g")
...
.on("mouseover", function(d) {
if (d.matches) {
return tooltip.style("visibility", "visible")
.text( function(d) { return d.name; } );
}
} )
...
;
When testing with just d.name, everything works fine. However, my attempt at creating a more complex function doesn't seem to be functioning properly. The text in the tooltip remains empty. Strangely, if I remove the function and directly use d.name, it works as expected.
if (d.matches) {
return tooltip.style("visibility", "visible")
.text( d.name );
}
This leads me to believe that the issue lies with implementing a custom function in this context. Any insights on what might be causing this problem would be greatly appreciated.