forked from westonruter/svg-tree-drawer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
89 lines (84 loc) · 3.04 KB
/
example.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
87
88
89
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>SVG Tree Drawer Example</title>
<meta property="og:image" content="http://westonruter.github.com/svg-tree-drawer/example.png" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="svg-tree-drawer.js"></script>
<style>
svg text {
padding:0.5em;
padding-left:0.20em;
padding-right:0.20em;
}
svg g.collapsed g text {
padding-left:0.5ex;
padding-right:0.5ex;
}
svg line,
svg polyline {
font-size:1em; /*height not honored here by WebKit*/
}
svg polyline {
fill:none;
}
.shortTree line,
.shortTree polyline {
font-size:0.25em;
}
.tallTree line,
.tallTree polyline {
font-size:2em;
}
</style>
</head>
<body>
<h1><a href="http://github.com/westonruter/svg-tree-drawer">SVG Tree Drawer</a> Example</h1>
<p><em>For a more sophisticated example, see an <a href="syntax-diagrammer/example-tree-with-avms.xhtml">example tree with <abbr title="Attribute Value Matricies">AVMs</abbr></a> (note served as <code>application/xhtml+xml</code> with inline MathML).</em></p>
<p>
<button onclick="tree.root.extended = !tree.root.extended; tree.draw();">Toggle Extend</button>
<button onclick="tree.root.collapsed = !tree.root.collapsed; tree.draw();">Toggle Collapsed</button>
</p>
<p id="tree">The boy plays with the ball.</p>
<script>
var tree = new TreeDrawer(
document.getElementById('tree'),
{label:"S", extended: true, children: [
{label:"NP", children:[
{label:"D", children: [
{label:"The"}
]},
{label:"N", children: [
{label:"boy"}
]}
]},
{label:"VP", children:[
{label:"V", children: [
{label:"plays"}
]},
{label:"PP", children:[
{label:"P", children: [
{label:"with"}
]},
{label:"NP", children:[
{label:"D", children: [
{label:"the"}
]},
{label:"N", children: [
{label:"ball"}
]}
]},
]},
]}
]}
);
tree.draw();
</script>
<hr>
<footer>
<address><a rel="author" href="http://westonruter.github.com/">Weston Ruter</a></address>
<time pubdate>2010-09-03</time>
</footer>
</body>
</html>