force-graph icon indicating copy to clipboard operation
force-graph copied to clipboard

Change node hover label

Open Aassifh opened this issue 3 years ago • 3 comments

When hovering over a node, a label is shown, i want to edit this label without changing the name value of the node, i couldn't find that on the documentation, any ideas ?

Thank you

Aassifh avatar Aug 27 '21 14:08 Aassifh

You can use the nodeLabel accessor method to customize the labels whichever way you want, f.e.:

.nodeLabel(node => /* your logic */)

vasturiano avatar Aug 27 '21 15:08 vasturiano

Is there a way to return a React.Element, an DOM element, or an image ? I would like further customization on this hover label, but not sure how to go about it. If it still needs to be a string, is there a way to format it ? Add
or a title/body style to it ? Thanks for your great work @vasturiano ! :)

pebubblemaps avatar Mar 25 '24 09:03 pebubblemaps

@pebubblemaps you can return an html string for basic formatting if you'd like. For Example:

.nodeLabel(node => `<b>${node.id}</b>`)

vasturiano avatar Mar 27 '24 21:03 vasturiano