-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
256 lines (238 loc) · 10.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
<!-- python -m SimpleHTTPServer 8080 //-->
<!-- http://bl.ocks.org/mbostock/4062045 //-->
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>FGBN</title>
<!-- JavaScript Libraries //-->
<script src="http://d3js.org/d3.v3.min.js"></script>
<!-- CSS Style //-->
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,900|Source+Code+Pro:300" rel="stylesheet" type="text/css">
<style>
body {
font-family: 'Source Sans Pro', sans-serif;
font-weight: 300;
}
b {
font-weight: 900;
}
.outline {
fill: none;
stroke: #888888;
stroke-width: 1px;
}
#tooltip {
font-size: 10pt;
font-weight: 900;
fill: #ffffff;
stroke: #000000;
stroke-width: 0.25px;
}
.node {
stroke: #ffffff;
stroke-weight: 1px;
}
.link {
fill: none;
stroke: #888888;
stroke-weight: 1px;
stroke-opacity: 0.5;
}
.highlight {
stroke: red;
stroke-weight: 4px;
stroke-opacity: 1.0;
}
.title { font: bold 85px sans-serif; fill:white;}
.subtitle { font: bold 21px sans-serif; fill:white;}
.panel-footer.panel-custom {
background: #000000;
color: white;
}
</style>
<script>
var width = 1960;
var height = 1500;
var margin = 20;
var pad = margin / 2;
var color = d3.scale.schemeDark2();
// Generates a tooltip for a SVG circle element based on its ID
function addTooltip(circle) {
var x = parseFloat(circle.attr("cx"));
var y = parseFloat(circle.attr("cy"));
var r = parseFloat(circle.attr("r"));
var text = circle.attr("id");
var tooltip = d3.select("#plot")
.append("text")
.text(text)
.attr("x", x)
.attr("y", y)
.attr("dy", -r * 2)
.attr("id", "tooltip");
var offset = tooltip.node().getBBox().width / 2;
if ((x - offset) < 0) {
tooltip.attr("text-anchor", "start");
tooltip.attr("dx", -r);
}
else if ((x + offset) > (width - margin)) {
tooltip.attr("text-anchor", "end");
tooltip.attr("dx", r);
}
else {
tooltip.attr("text-anchor", "middle");
tooltip.attr("dx", 0);
}
}
var vis = d3.select("#chart")
.append("svg:svg")
.attr("width", w)
.attr("height", h)
.attr("pointer-events", "all")
.append('svg:g')
.call(d3.behavior.zoom().on("zoom", redraw))
.append('svg:g');
vis.append('svg:rect')
.attr('width', w)
.attr('height', h)
.attr('fill', 'white');
function redraw() {
console.log("here", d3.event.translate, d3.event.scale);
vis.attr("transform",
"translate(" + d3.event.translate + ")"
+ " scale(" + d3.event.scale + ")");
}
function drawGraph(graph) {
var svg = d3.select("#force").append("svg")
.attr("width", width)
.attr("height", height);
// draw plot background
svg.append("rect")
.attr("width", width)
.attr("height", height)
.style("fill", "#000000");
svg.append("text")
.attr("x",width/5.5)
.attr("y",height/2)
.attr('class','title')
.text("First Green Bank Network");
svg.append("text")
.attr("x",width/5.5)
.attr("y",height/2 + height/10)
.attr('class','subtitle')
.text("Using Exponential Technology to Mobilize Global Blended Finance in Alignment with the UN's 17 SDG's.");
// create an area within svg for plotting graph
var plot = svg.append("g")
.attr("id", "plot")
.attr("transform", "translate(" + pad + ", " + pad + ")");
// https://github.com/mbostock/d3/wiki/Force-Layout#wiki-force
var layout = d3.layout.force()
.size([width - margin, height - margin])
.charge(-120)
.linkDistance(function(d, i) {
return (d.source.group == d.target.group) ? 50 : 100;
})
.nodes(graph.nodes)
.links(graph.links)
.start();
drawLinks(graph.links);
drawNodes(graph.nodes);
// add ability to drag and update layout
// https://github.com/mbostock/d3/wiki/Force-Layout#wiki-drag
d3.selectAll(".node").call(layout.drag);
// https://github.com/mbostock/d3/wiki/Force-Layout#wiki-on
layout.on("tick", function() {
d3.selectAll(".link")
.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
d3.selectAll(".node")
.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
});
}
function tick(e) {
// Push different nodes in different directions for clustering.
var k = 6 * e.alpha;
graph.nodes.forEach(function(o, i) {
o.y += i & 1 ? k : -k;
o.x += i & 2 ? k : -k;
});
node.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
}
// Draws nodes on plot
function drawNodes(nodes) {
// used to assign nodes color by group
var color = d3.scale.category20();
// https://github.com/mbostock/d3/wiki/Force-Layout#wiki-nodes
d3.select("#plot").selectAll(".node")
.data(nodes)
.enter()
.append("circle")
.attr("class", "node")
.attr("id", function(d, i) { return d.name; })
.attr("cx", function(d, i) { return d.x; })
.attr("cy", function(d, i) { return d.y; })
.attr("r", function(d, i) { return 5; })
.style("fill", function(d, i) { return color(d.group); })
.on("mouseover", function(d, i) { addTooltip(d3.select(this)); })
.on("mouseout", function(d, i) { d3.select("#tooltip").remove(); });
}
// Draws edges between nodes
function drawLinks(links) {
var scale = d3.scale.linear()
.domain(d3.extent(links, function(d, i) {
return d.value;
}))
.range([1, 6]);
// https://github.com/mbostock/d3/wiki/Force-Layout#wiki-links
d3.select("#plot").selectAll(".link")
.data(links)
.enter()
.append("line")
.attr("class", "link")
.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; })
.style("stroke-width", function(d, i) {
return scale(d.value) + "px";
})
.style("stroke-dasharray", function(d, i) {
return (d.value <= 1) ? "2, 2" : "none";
});
}
</script>
</head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<body>
<div align="center" id="force"></div>
<!-- <a href="https://informationisbeautiful.net/beautifulnews/839-cost-solar-wind" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/839/839-cost-solar-wind.svg" alt="The Cost of Solar and Wind Energy is Plunging" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/584-usa-wind-power" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/584/584-usa-wind-power.svg" alt="The USA Is Ripe for Wind Power" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/1085-china-renewables" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/1085/1085-china-renewables.svg" alt="China could generate half its power from renewables by 2040" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/1079-us-power-grid" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/1079/1079-us-power-grid.svg" alt="Just $4.5 Trillion Would Transform -->
<!-- the US Power Grid to 100% Renewables" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/455-california-energy-mix" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/455/455-california-energy-mix.svg" alt="Almost Half of California's Electricity Now Comes From Renewables" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/1059-renewables-investment" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/1059/1059-renewables-investment.svg" alt="We're Investing Twice as Much in Renewables vs Fossil Fuels" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/14-texas-energy-mix" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/14/14-texas-energy-mix.svg" alt="Even Texas Is 32% Carbon Free" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/15-renewables-outpacing-coal" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/15/15-renewables-outpacing-coal.svg" alt="Renewables Are Rapidly Outpacing Coal" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/586-cost-renewables-falling" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/586/586-cost-renewables-falling.svg" alt="The Cost of Renewables Is Falling Fast" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/18-india-solar-capacity" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/18/18-india-solar-capacity.svg" alt="India's Solar Power Capacity Quadruples" /></a> -->
<!-- <a href="https://informationisbeautiful.net/beautifulnews/562-adding-more-solar-power" target="_blank"><img style="height:300px;width:auto;" src="https://s3.amazonaws.com/infobeautiful-bnews/images/562/562-adding-more-solar-power.svg" alt="Every Year We're Adding More and More Solar Power" /></a> -->
<footer class="page-footer font-small panel-footer panel-custom">
<!-- <div class="footer-copyright text-left py-3"> -->
<!-- Copyright -->
<div class="footer-copyright text-center py-3">© 2020 Copyright:
<a href="https://firstgreenbank.network"> firstgreenbank.network</a></br>
1631 Dickson Avenue Suite 1100 Kelowna British Columbia V1Y 0B5 Canada</br>
</div>
<!-- Copyright -->
</footer>
<script>
d3.json("pcap_export.json", drawGraph);
</script>
</body>
</html>