This repository was archived by the owner on Jul 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
84 lines (68 loc) · 1.8 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="node_modules/d3-sankey-diagram/build/d3-sankey-diagram.min.js"></script>
<script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>
<style>
html,
body {
margin: 0;
padding: 0;
overflow: hidden
}
svg {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%
}
svg .link {
opacity: 0.8;
fill: steelblue;
}
svg .link:hover {
opacity: 1;
}
svg g.sankey {
font-size: 10pt;
}
svg .node line {
stroke-width: 1px;
stroke: #000;
}
svg .node-type-process line {
stroke-width: 4px;
stroke: #888;
}
svg .group rect {
fill: #eee;
stroke: #bbb;
stroke-width: 0.5px;
}
svg .group text {
fill: #999;
}
</style>
</head>
<body>
<svg id="graph" width="1000" height="1000"></svg>
<script>
const layout = d3.sankey()
.extent([[200, 10], [800, 500]]);
const color = d3.scaleOrdinal(d3.schemeDark2);
const diagram = d3.sankeyDiagram()
.nodeTitle(d => d.title || d.id)
.linkColor(d => d.color || color(d.source.id));
d3.json('data.json', data => {
var svg = d3.select("#graph")
.append("g")
.datum(layout.scale(null)(data))
.call(diagram);
});
</script>
</body>
</html>