-
Notifications
You must be signed in to change notification settings - Fork 76
/
d3sparql-circlepack.html
94 lines (92 loc) · 2.53 KB
/
d3sparql-circlepack.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
90
91
92
93
94
<!DOCTYPE html>
<meta charset="UTF-8">
<html>
<head>
<link rel="stylesheet" type="text/css" href="lib/bootstrap/css/bootstrap.css"/>
<script src="lib/d3/d3.v3.min.js"></script>
<script src="d3sparql.js"></script>
<script>
function exec() {
var endpoint = d3.select("#endpoint").property("value")
var sparql = d3.select("#sparql").property("value")
d3sparql.query(endpoint, sparql, render)
}
function render(json) {
var config = {
// for d3sparql.tree()
"root": "root_name",
"parent": "parent_name",
"child": "child_name",
// for d3sparql.circlepack()
"width": 800,
"height": 800,
"diameter": 700,
"selector": "#result"
}
d3sparql.circlepack(json, config)
}
function exec_offline() {
d3.json("cache/taxonomy/tardigrada.json", render)
}
function toggle() {
d3sparql.toggle()
}
</script>
<style>
text {
font-size: 11px;
pointer-events: none;
}
text.parent {
fill: #1f77b4;
}
circle {
fill: #ccc;
stroke: #999;
pointer-events: all;
}
circle.parent {
fill: #1f77b4;
fill-opacity: .1;
stroke: steelblue;
}
circle.parent:hover {
stroke: #ff7f0e;
stroke-width: .5px;
}
circle.child {
pointer-events: none;
}
</style>
</head>
<body>
<div id="query" style="margin: 10px">
<h1>d3circlepack</h1>
<form class="form-inline">
<label>SPARQL endpoint:</label>
<div class="input-append">
<input id="endpoint" class="span5" value="http://togostanza.org/sparql" type="text">
<button class="btn" type="button" onclick="exec()">Query</button>
<button class="btn" type="button" onclick="exec_offline()">Use cache</button>
<button class="btn" type="button" onclick="toggle()"><i id="button" class="icon-chevron-up"></i></button>
</div>
</form>
<textarea id="sparql" class="span9" rows=15>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX tax: <http://ddbj.nig.ac.jp/ontologies/taxonomy/>
SELECT DISTINCT ?root_name ?parent_name ?child_name
FROM <http://togogenome.org/graph/taxonomy>
WHERE
{
VALUES ?root_name { "Tardigrada" }
?root tax:scientificName ?root_name .
?child rdfs:subClassOf+ ?root .
?child rdfs:subClassOf ?parent .
?child tax:scientificName ?child_name .
?parent tax:scientificName ?parent_name .
}
</textarea>
</div>
<div id="result"></div>
</body>
</html>