I am currently working on implementing a generalized tooltip feature. This tooltip will display the name and other relevant data of the active node. For example, if node 3 is currently active, the tooltip will show the name and distance (not link distance) of node 3.
However, I am facing an issue in selecting the desired node. Every time I attempt to select it, I encounter the error message "SyntaxError: Document.querySelector: '#3' is not a valid selector".
Below is the code snippet:
var currNode = 3; // The ID of the active node
var position = d3.select("#" + currNode).name // The data to be displayed, such as the name
Subsequently, the variable "position" is utilized in the tooltip as follows:
var tooltip = this.svg.append("text")
.attr("x", 25)
.attr("y", 25)
.text("Your current position: " + position )
.style("font-weight", 550)
.style("font-size", 18)
Has anyone discovered an alternative method for accessing the data of a specific node?
Thank you in advance!