-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
402 lines (351 loc) · 12.5 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title lang="en">Visialization of Citation Network</title>
<title lang="ja">学会間の引用関係の可視化</title>
<meta name="description" lang="en" content="Visualization of academic conferences networked by citation">
<meta name="description" lang="ja" content="学会を引用関係に基づいて可視化したものです.ノードが学会,エッジが引用関係をあらわしています.">
<meta property="og:title" lang="en" content="Visialization of Citation Network" />
<meta property="og:title" lang="ja" content="学会間の引用関係の可視化" />
<meta property="og:description" lang="en" content="Visualization of academic conferences networked by citation">
<meta property="og:description" lang="ja" content="学会を引用関係に基づいて可視化したものです.ノードが学会,エッジが引用関係をあらわしています.">
<meta property="og:type" content="website" />
<meta property="og:url" content="https://maruta.github.io/visnet-dml/full/" />
<meta property="og:image" content="ogpimage.png" />
<style>
html {
width: 100%;
height: 100%;
overflow: hidden;
}
body {
font: 11px sans-serif;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
position: relative;
background: rgb(0, 4, 46);
}
svg {
width: 100%;
height: 100%;
display: block;
}
#note {
pointer-events: none;
position: absolute;
bottom: 0;
font-size: 9px;
font-weight: 200;
margin-left: 20px;
color: #cccccc;
}
h2 {
font-size: 10px;
font-weight: inherit;
margin-bottom: 0;
}
h3 {
margin-top: 0;
font-size: 10px;
font-weight: inherit;
}
#note a {
pointer-events: all;
color: inherit;
}
ol {
padding-left: 2em;
margin-bottom: 0;
}
ol li {
list-style-type: none;
counter-increment: cnt;
position: relative;
}
ol li:before {
display: marker;
position: absolute;
left: -2em;
content: "[" counter(cnt) "] ";
}
.overlay {
fill: none;
pointer-events: all;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
.node {
stroke: #666;
stroke-opacity: 0.8;
stroke-width: 0.1px;
opacity: 0.8;
fill: rgba(255,255,255,0.8);
}
.node.Automatica {
fill: #ff8585;
stroke: #000;
}
.node.ICML {
fill: #9affa4;
stroke: #000;
}
.node.active {
fill: #ff4d00;
stroke-width: 1.5px;
stroke: #ff4d00;
}
.node.searched {
fill: #fff500;
stroke-width: 1.5px;
stroke: #fff500;
}
.edge {
fill: none;
stroke: #3c74b5;
stroke-opacity: 0.4;
}
.edge.active {
stroke: #ff0000;
stroke-opacity: 1;
}
.edge.searched {
stroke: #fff500;
stroke-opacity: 1;
}
.tooltip {
position: absolute;
color: #fff;
padding: 2px 4px;
background: rgba(34, 51, 112, 0.6);
pointer-events: none;
font-family: Arial, sans-serif;
font-size: 14px;
width: auto;
}
.tooltip .citation {
font-size: 80%;
}
.tooltip .cname {
font-weight: bolder;
}
.tooltip .cnum {
font-weight: bolder;
}
#searchbox {
position: absolute;
top: 20px;
right: 20px;
font-size: 14px;
font-weight: 200;
width: 20em;
padding: 5px;
background: rgba(0, 4, 46, 0.5);
border: solid 0.5px #cccccc;
color: #cccccc;
}
</style>
</head>
<body>
<script src="//d3js.org/d3.v5.min.js"></script>
<script>
var width = 960,
height = 500,
asratio = height / width,
xdomain = [-400, 800],
ydomainsize = (xdomain[1] - xdomain[0]) * asratio,
ydomaincenter = -0;
ydomain = [ydomaincenter - ydomainsize / 2, ydomaincenter + ydomainsize / 2];
function selectorSanitize(val) {
return "sel" + val.replace(/[ !"#$%&'()*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '');
}
var xValue = function(d) {
return d.x;
},
xScale = d3.scaleLinear().domain(xdomain).range([0, width]),
xMap = function(d) {
return xScale(xValue(d));
}
var yValue = function(d) {
return d.y;
},
yScale = d3.scaleLinear().domain(ydomain).range([height, 0]),
yMap = function(d) {
return yScale(yValue(d));
}
var svg_base = d3.select("body").append("svg")
.attr("preserveAspectRatio", "xMidYMid slice")
.attr("viewBox", "0 0 " + width + " " + height)
.append("g");
svg_base.append("rect")
.attr("class", "overlay")
.attr("width", "100%")
.attr("height", "100%");
var svg = svg_base
.call(d3.zoom().scaleExtent([0.6, 30]).on("zoom", zoom))
.append("g");
function zoom() {
svg.attr("transform", d3.event.transform);
if (tooltip_target != null) {
placeTooltip(tooltip_target);
}
}
var tooltip = d3.select("body").append("div")
.attr("class", "tooltip")
.style("opacity", 0);
var tooltip_target = null;
function showTooltip(tgt) {
tooltip_target = tgt;
var d = tgt.data()[0];
tooltip.transition()
.duration(10)
.style("opacity", .9);
tooltip.html("<span class='cname'>" + d.label + "</span><br><span class='citation'>cited by <span class='cnum'>" + d.size + "</span></span>")
placeTooltip(tgt);
}
function placeTooltip(tgt) {
var ctm = tgt.node().getCTM();
var coords = getScreenCoords(tgt.attr("cx"), tgt.attr("cy"), ctm);
tooltip.style("left", (coords.x + 5) + "px")
.style("top", (coords.y - 18) + "px");
}
function hideTooltip() {
tooltip.transition()
.duration(500)
.style("opacity", 0);
}
function getScreenCoords(x, y, ctm) {
var xn = ctm.e + x * ctm.a + y * ctm.c;
var yn = ctm.f + x * ctm.b + y * ctm.d;
return {
x: xn,
y: yn
};
}
d3.json("data.small.json").then(function(data) {
var edges = [];
var nodes = {};
var searchNodeList = document.getElementById('nodelist');
data.nodes.forEach(function(d) {
nodes[d.id] = {
x: d.x,
y: d.y,
label: d.id,
category: d.attributes.category,
id: d.id,
size: d.attributes.cited
};
var option = document.createElement('option');
option.value = d.id;
searchNodeList.appendChild(option);
});
data.edges.forEach(function(d) {
if(d.size<400) return;
var edge = {
points: [{
x: nodes[d.source].x,
y: nodes[d.source].y
}, {
x: (nodes[d.source].x + nodes[d.target].x) / 2 + (nodes[d.source].y - nodes[d.target].y) * 0.3,
y: (nodes[d.source].y + nodes[d.target].y) / 2 - (nodes[d.source].x - nodes[d.target].x) * 0.3,
}, {
x: nodes[d.target].x,
y: nodes[d.target].y
}],
weight: d.size,
source: d.source,
target: d.target
};
edges.push(edge);
});
var wScale = d3.scaleLinear().domain([50, 30000]).range([0.1, 10]);
var lineFunction = d3.line().x(function(d) {
return xScale(d.x);
}).y(function(d) {
return yScale(d.y);
}).curve(d3.curveCatmullRom);
svg.selectAll(".edge")
.data(edges)
.enter().append("path")
.attr("class", function(d) {
return "edge " + "edge-" + selectorSanitize(d.source) + " edge-" + selectorSanitize(d.target);
})
.attr("stroke-width", function(d) {
return wScale(d.weight)
})
.attr("d", function(d) {
return lineFunction(d.points);
});
svg.selectAll(".node")
.data(d3.values(nodes))
.enter().append("circle")
.attr('class', function(d) {
return 'node ' + selectorSanitize(d.label) + " " + (d.category === undefined ? '' : selectorSanitize(d.category));
})
.attr("cx", xMap)
.attr("cy", yMap)
.attr("r", function(d) {
return 0.15 * Math.pow(d.size, 0.2)
})
.on("mouseover", function(d) {
d3.select(this).classed('active', true);
d3.selectAll('.edge-' + selectorSanitize(d.id)).classed('active', true);
showTooltip(d3.select(this));
})
.on("mouseout", function(d) {
d3.select(this).classed('active', false);
d3.selectAll('.edge-' + selectorSanitize(d.id)).classed('active', false);
tooltip.transition()
.duration(500)
.style("opacity", 0);
});
});
var oldquery = "";
function updateSearch(e) {
var query = selectorSanitize(e.value);
if (query != "") {
var searched = d3.select("." + query);
if (!searched.empty()) {
searched.classed('searched', true);
var d = searched.data()[0];
d3.selectAll('.edge-' + selectorSanitize(d.id)).classed('searched', true);
showTooltip(searched);
} else {
hideTooltip();
}
if (query != oldquery) {
if (oldquery != "") {
d3.select("." + oldquery).classed('searched', false);
d3.selectAll('.edge-' + oldquery).classed('searched', false);
}
oldquery = query;
}
}
}
</script>
<div id="note">
<h2>Visualization of Citation Network</h2>
<h3>by Ichiro Maruta</h3>
<p>
This visualization is based on <a href="https://aminer.org/citation">Citation Network Dataset</a> by <a href="https://aminer.org/">AMiner</a> [1]<br>
<ol>
<li>Jie Tang, Jing Zhang, Limin Yao, Juanzi Li, Li Zhang, and Zhong Su.<br> ArnetMiner: Extraction and Mining of Academic Social Networks. <br> In Proceedings of SIGKDD'2008. pp.990-998.</li>
</ol>
</p>
</div>
<input id="searchbox" name="searchbox" type="text" placeholder="search..." list="nodelist" oninput="updateSearch(this)" />
<datalist id="nodelist"></datalist>
<script>
if(window.location.hash=="#minimum") {
document.getElementById('note').style.display='none';
document.getElementById('searchbox').style.display='none';
}
</script>
</body>
</html>