Mouseover not registering

I have a graph builder where you can add new nodes.

I need to run a function when you hover over these new nodes,

Currently when I hover these nodes the mouseover function is not registering. Only the first time when you create a new node

Here is what I tried so far:

I don’t see any mouseover listener in the notebook you shared. Have you shared the latest version?

I did notice another bug in your code: in the spawn function you are appending a text element to node after joining, which means you’re adding text elements to nodes that already have them. I expect you only mean to add the text element to the new node, which would need to be part of the enter clause of the join.

    node = node
        enter => enter.append("circle").attr("r", 0)
          .call(enter => enter.transition().attr("r", 15))
          .call(enter => enter.append("text").text(d => d.index))
        update => update,
        exit => exit.remove()

Edit: I also realized you’re adding text elements to circle elements, so those text elements will be ignored. You’ll need to change node to be G elements, and then add both circle and text elements to that group element.

1 Like

You’re right I forgot to hit publish my bad.

I’ve updated it now:

Okay yes that makes sense. I moved the text and circle element to be appended to enter selection but the text still doesn’t appear.

Edit: (I updated the notebook) I seem to have fixed the text issue, I created a new element called label and attached an text element to that.

I found the bug with mousedown and mouseup. It appears to only work for the right click button. Is this always the case? And is there a way to change it?