ErikGartner / dTree

A library for visualizing data trees with multiple parents, such as family trees. Built on top of D3.
https://treehouse.gartner.io/ErikGartner/58e58be650453b6d49d7
MIT License
521 stars 139 forks source link

How do I display images in nodes? #82

Closed jpdaut closed 5 years ago

jpdaut commented 5 years ago

Instead of text, can nodes be images? Or, can nodes embed image and text?

ErikGartner commented 5 years ago

Yes for sure! You just write callback for the rendering of the nodes (using the nodeRenderer callback) then your nodes can be anything written in html, like a div containing an image and text.

jpdaut commented 5 years ago

Great. Can you direct me to a model on how to make the callback? That would be very appreciated, thank you.

ErikGartner commented 5 years ago

Yes, I've updated the official JSFiddle to use the nodeRenderer callback. It just sets it to the default value but you can change it to include tags for images etc. Basically you can use any valid HTML for foreign objects in SVG.

jpdaut commented 5 years ago

Fantastic. This works great! Thank you