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

Example on how to implement callbacks? #66

Closed shobeck closed 6 years ago

shobeck commented 6 years ago

Hi! Love this library. I would like to style the text inside the node using the extra{}. I don't see an example of how to do this with a renderer. Any help is appreciated.

'name': 'Donald Smith', 'class': 'man', 'extra': { 'nickname': 'John' },....

dtree.init(mydata, { target: '#graph', debug: true, height: 1200, width: 1500, callbacks: { }, margin: { top: 0, right: 0, bottom: 0, left: 0 }, nodeWidth: 100, styles: { node: 'node', linage: 'linage', marriage: 'marriage', text: 'nodeText' } });

Thanks! Sheila

ErikGartner commented 6 years ago

Hi Sheila!

I've updated the jsfiddle as well as the demo example in the test folder to use a custom textRenderer callback that displays the nickname if present in the extra data field.

In general have a look at the default implementations to see how to use them. See below: https://github.com/ErikGartner/dTree/blob/64e32128eeaebfd316aaefb488ca3e9ed99e072e/src/builder.js#L293

Best, Erik

shobeck commented 6 years ago

Thank you very much! That was fast!

On January 30, 2018 at 12:37:29 PM, Erik Gärtner (notifications@github.com) wrote:

Hi Sheila!

I've updated the jsfiddle as well as the demo example https://github.com/ErikGartner/dTree/tree/master/test/demo in the test folder to use a custom textRenderer callback that displays the nickname if present in the extra data field.

In general have a look at the default implementations to see how to use them. See below: https://github.com/ErikGartner/dTree/blob/64e32128eeaebfd316aaefb488ca3e9ed99e072e/src/builder.js#L293

Best, Erik

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ErikGartner/dTree/issues/66#issuecomment-361672421, or mute the thread https://github.com/notifications/unsubscribe-auth/AiTUSY4QjwgopoorQXX0SRXqne9_HQExks5tP1NYgaJpZM4Ryr44 .