Skip to content

Instantly share code, notes, and snippets.

@abubelinha
Forked from ErikGartner/.treehouse
Last active April 5, 2020 18:36
Show Gist options
  • Save abubelinha/5d83a47203418c29f9ceb842cad6f5d1 to your computer and use it in GitHub Desktop.
Save abubelinha/5d83a47203418c29f9ceb842cad6f5d1 to your computer and use it in GitHub Desktop.
dTree Demo

dTree

dTree is the open source graph library that powers this site. It is written by the Swedish computer engineering student Erik Gärtner. It builds on top of D3 and aims at being a simple yet extensive library for building family trees.

Treehouse

This site acts as a playground that allows for easy demoing and hosting of dTree graphs.

Stylesheet

The stylesheet here is simple and only intended to show an easy example of what is possible. Most elementes in the graph can be customized using stylesheets and custom renderers.

Custom renderer

When using dTree on your own site you have the possibility to to fully customize how the library renders the text and the node. For security purposes Treehouse only allows for custom html templates using a handlebar template.

In this example the renderer displays the name of the node and the "favorite color" if the data is available.

[{
"name": "J.G.F.",
"class": "man",
"textClass": "emphasis",
"extra": {"born":"1901","dead":"1990"},
"marriages": [{
"spouse": {
"name": "MC.D.A.",
"class": "woman", "extra": {"born":"","dead":""}
},
"children": [{
"name": "X.G.D.", "class": "man", "extra": {"born":"1941", "dead":""},
"marriages": [{
"spouse": {
"name": "MC.SL.M.", "class": "woman", "extra": {"born":"1946", "dead":""}
},
"children": [{
"name": "D.G.SL.", "class": "man", "extra": {"born":"1971", "dead":""},
"marriages": [{
"spouse": {
"name": "S.G.V.", "class": "woman", "extra": {"born":"1972", "dead":""}
},
"children": [
{
"name": "C.G.G.", "class": "man", "extra": {"born":"2009", "dead":""}
}
]
}]
}, {
"name": "O.G.SL.", "class": "woman", "extra": {"born":"1976", "dead":""}
}, {
"name": "M.G.SL.", "class": "woman", "extra": {"born":"1976", "dead":""},
"marriages": [{
"spouse": {
"name": "JM.V.P.", "class": "man", "extra": {"born":"1966", "dead":""}
},
"children": [
{
"name": "C.V.G.", "class": "woman", "extra": {"born":"2012", "dead":""}
},
{
"name": "M.V.G.", "class": "woman", "extra": {"born":"2015", "dead":""}
}
]
}]
}]
}]
}]
}]
}]
{{name}}
{{#if extra}}
<br>({{extra.born}}-{{extra.dead}})
{{/if}}
svg {
font: 10px sans-serif;
}
.linage {
fill: none;
stroke: #000;
}
.marriage {
fill: none;
stroke: black;
}
.man {
background-color: lightblue;
border-style: solid;
border-width: 1px;
}
.woman {
background-color: pink;
border-style: solid;
border-width: 1px;
}
.emphasis{
font-style: italic;
}
p {
padding:0;
margin:0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment