-
Notifications
You must be signed in to change notification settings - Fork 142
/
index.html
86 lines (83 loc) · 1.79 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<style type="text/css">
body {
font: 10px sans-serif;
}
.linage {
fill: none;
stroke: #000;
}
.marriage {
fill: none;
stroke: black;
}
.marriageNode {
background-color: black;
border-radius: 50%;
}
.man {
background-color: lightblue;
border-style: solid;
border-width: 1px;
box-sizing: border-box;
}
.woman {
background-color: pink;
border-style: solid;
border-width: 1px;
box-sizing: border-box;
}
.emphasis{
font-style: italic;
}
p {
padding:0;
margin:0;
}
svg {
border-style: solid;
border-width: 1px;
}
</style>
<script src="https://cdn.jsdelivr.net/lodash/4.17.4/lodash.min.js"></script>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="dTree.min.js"></script>
<body>
<h1>Demo</h1>
<div id="graph"></div>
<script>
treeJson = d3.json("data.json", function(error, treeData) {
dTree.init(treeData,
{
target: "#graph",
debug: true,
hideMarriageNodes: true,
marriageNodeSize: 5,
height: 800,
width: 1200,
callbacks: {
nodeClick: function(name, extra) {
alert('Click: ' + name);
},
nodeRightClick: function(name, extra) {
alert('Right-click: ' + name);
},
textRenderer: function(name, extra, textClass) {
if (extra && extra.nickname)
name = name + " (" + extra.nickname + ")";
return "<p align='center' class='" + textClass + "'>" + name + "</p>";
},
marriageClick: function(extra, id) {
alert('Clicked marriage node' + id);
},
marriageRightClick: function(extra, id) {
alert('Right-clicked marriage node' + id);
},
}
});
});
</script>
</body>
</html>