d3-flame-graph icon indicating copy to clipboard operation
d3-flame-graph copied to clipboard

make node text a link

Open iliasaz opened this issue 4 years ago • 2 comments

I have a requirement to navigate to another page when a user clicks on a particular node text (not the frame itself). I tried embedding an tag in the data element itself, but it comes out as text/html, no rendered. Is there a function I could use to inject html rendering of the node text? Will it be clickable?

Thanks!

iliasaz avatar Aug 14 '21 17:08 iliasaz

Hey @iliasaz Setting the node text to something other than pure text is not an option right now, and I cant see a simple workaround. What probably needs to be done is to change the node creation call to include an SVG <a> before the text name. See https://github.com/spiermar/d3-flame-graph/blob/master/src/flamegraph.js#L346.

This would require a custom build right now, since there's no option to change the default behavior. Something in the lines of the setDetailsHandler option. See https://github.com/spiermar/d3-flame-graph/blob/master/src/flamegraph.js#L791.

If you're interested in implementing this and opening a PR, I'm happy to merge it. Should be a matter of replacing the .text call with a function that can be overridden.

spiermar avatar Oct 12 '21 17:10 spiermar

Related to #94.

spiermar avatar Oct 12 '21 18:10 spiermar