-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
1705 lines (1566 loc) · 62.3 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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="content-Type" content="text/html; charset=utf-8" />
<meta name="description"
content="Sustainable Energy Transitions Exploratorium #energy #SDG #sustainability #d3plus #dataviz #d3js @csaladenes" />
<meta name="keywords"
content="csaladenes, d3.js, data visualization, infographic, d3plus, d3, data visualization, mit oec, mit, mit atlas, macro connections, set, system dynamics, sustainable energy transitions, renewable energy, energy return on energy invested, eroei, eroi, sgouris sgouridis, denes csala, ssgouridis, dcsala, science, nature, article, d3.js, ipython, ugo bardi, ugo, peak oil, hubbert curve, carbon cap, emissions cap, fossil fuels, co2 emissions greenhouse gas emissions" />
<meta property="og:image" content="https://netset.csaladen.es/snapshot.png" />
<meta property="twitter:image" content="https://netset.csaladen.es/snapshot.png" />
<meta property="og:description"
content="Sustainable Energy Transitions Exploratorium #energy #SDG #sustainability #d3plus #dataviz #d3js @csaladenes" />
<meta property="twitter:description"
content="Sustainable Energy Transitions Exploratorium #energy #SDG #sustainability #d3plus #dataviz #d3js @csaladenes" />
<meta property="og:title" content="Sustainable Energy Transitions Exploratorium" />
<meta property="twitter:title" content="Sustainable Energy Transitions Exploratorium" />
<meta http-equiv="content-Type" content="text/html; charset=utf-8" />
<meta property="og:url" content="https://netset.csaladen.es" />
<meta property="twitter:url" content="https://netset.csaladen.es" />
<meta property="og:site_name" content="Sustainable Energy Transitions Exploratorium" />
<meta property="fb:admins" content="100943737036023614165" />
<link rel="shortcut icon" href="favicon.ico" />
<link rel="publisher" href="https://plus.google.com/106181965793093327960" />
<title>Sustainable Energy Transitions Exploratorium</title>
<style>
@font-face {
font-family: "Arial";
src: url(font/Arial-Regular.ttf) format("truetype");
}
.logo,
.viz,
#social {
-webkit-transition: opacity 0.5s;
-moz-transition: opacity 0.5s;
-o-transition: opacity 0.5s;
-ms-transition: opacity 0.5s;
transition: opacity 0.5s;
}
.viz {
width: -moz-calc(100% - 200px);
width: -webkit-calc(100% - 200px);
width: calc(100% - 200px);
}
#viz6drop {
margin-left: -moz-calc(50% - 480px);
margin-left: -webkit-calc(50% - 480px);
margin-left: calc(50% - 480px);
}
#viz6drop2 {
margin-left: -moz-calc(50% - 90px);
margin-left: -webkit-calc(50% - 90px);
margin-left: calc(50% - 90px);
}
a {
font-family: Arial;
text-decoration: none;
}
a:hover {
font-family: Arial;
text-decoration: underline;
}
a:visited {
color: #444;
}
.logo:hover {
cursor: pointer;
}
#social {
text-decoration: none;
padding-top: 1px;
white-space: nowrap;
overflow: hidden;
}
.socialico {
width: 21px;
height: 21px;
}
.rotmenu {
-webkit-transition: -webkit-transform .8s ease-in-out;
transition: transform .8s ease-in-out;
}
.rotmenu:hover {
-webkit-transform: rotate(-360deg);
transform: rotate(-360deg);
}
.rotmenu2 {
-webkit-transition: -webkit-transform .3s ease-in-out;
transition: transform .3s ease-in-out;
}
.rotmenu2:hover {
-webkit-transform: scale(1.1, 1.1);
transform: scale(1.1, 1.1);
}
</style>
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date(); a = s.createElement(o),
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-40713687-6', 'auto');
ga('send', 'pageview');
</script>
<script type="text/javascript">var switchTo5x = true;</script>
<script type="text/javascript" src="https://w.sharethis.com/button/buttons.js"></script>
<script
type="text/javascript">stLight.options({ publisher: "505a26ad-d820-47bd-a500-7f49d04a30f5", doNotHash: false, doNotCopy: false, hashAddressBar: true, shorten: false });</script>
</head>
<!-- load D3js -->
<script src="js/d3.js"></script>
<!-- load topojson after D3js -->
<script src="js/d3.geo.projection.v0.min.js"></script>
<script src="js/topojson.min.js"></script>
<!-- load D3plus after both -->
<script src="js/d3plus.js"></script>
<script src="js/jszip.min.js"></script>
<script src="js/JSZipUtils.min.js"></script>
<script src="js/svgexport.js"></script>
<body link="#444">
<!-- create container element for visualization -->
<a id="pngdownload" href="" download=""
style="visibility:hidden;display:none;position:fixed;top:0px;left:0px;width:0px;height:0px;"></a>
<div style="position: fixed;
left: 50%;
top: 50%;
height: 150px;
margin-top: -168px;
width: 150px;
margin-left: -170px;" class="loading">
<img style="position: absolute;
left: 0px;
top: 0px;
z-index: 49;
height: 170px;
width: 170px;
margin-top: -45px;
margin-left: -10px;" src="icon/b.gif" />
<img style="position: absolute;
left: 0px;
top: 0px;
z-index: 50;
height: 100px;
width: 100px;
margin-top: 0px;
margin-left: 25px;
border:none" src="icon/netset_logo.png" />
</div>
<div style="position: fixed;
right: 20px;
top: 70px;
z-index: 101;
opacity: 0;
height: 100%;
width:190px;" class="logo">
<div style="position: fixed;
right: 15px;
top: 15px;
z-index:200;" alt="Select Scenario" title="Select Scenario" id="scenariolist"></div>
<img class="rotmenu2" style="position: absolute;
right: 60px;
top:250px;
height: 52px;
border: solid 1px #888; background-color:rgba(251,212,31,1);
width: 52px;" src="img/world.png" alt="GHI Resource Plot" title="GHI Resource Plot" onclick='show(5);'>
<img class="rotmenu2" style="position: absolute;
right: 0px;
top: 250px;
height: 52px;
border: solid 1px #888; background-color:rgba(207,19,19,1);
width: 52px;" src="img/nw.png" alt="Resource network" title="Resource network" onclick='show(6);'>
<img class="rotmenu2" style="position: absolute;
right: 60px;
top: 420px;
height: 52px;
border: solid 1px #888; background-color:rgba(207,19,19,1);
width: 52px;" src="img/nw.png" alt="Influence" title="Influence" onclick='show(7);'>
<img class="rotmenu2" style="position: absolute;
right: 120px;
top: 250px;
height: 52px;
border: solid 1px #888; background-color:rgba(112,133,16,1);
width: 52px;" src="img/res.png" alt="Resource Distribution Plots" title="Resource Distribution Plots"
onclick='show(4);'>
<img class="rotmenu2" style="position: absolute;
right: 60px;
top:335px;
height: 52px;
border: solid 1px #888;
width: 52px;" src="icon/stacked.png" alt="Timeline" title="Timeline" onclick='show(1);'>
<img class="rotmenu2" style="position: absolute;
right: 0px;
top: 335px;
height: 52px;
border: solid 1px #888;
width: 52px;" src="icon/tree.png" alt="Treemap" title="Treemap" onclick='show(2);'>
<img class="rotmenu2" style="position: absolute;
right: 120px;
top: 335px;
height: 52px;
border: solid 1px #888;
width: 52px;" src="icon/line.png" alt="Line Plot" title="Line Plot" onclick='show(3);'>
<a href="https://netset.csaladen.es" target="_self">
<img class="rotmenu2" class="rotmenu" style="position: absolute;
right: 40px;
top: 20px;
border: none;
width: 90px;height:90px;" src="icon/netset_logo.png" alt="Netset Logo">
<div style="position: absolute;
right: 40px;
top: 117px;
height: 22px;
color: #888;
font-size:20px;
font-family: Arial;
text-align:center;
white-space: nowrap;
width: 100px;" />NETSET 1.0
</div></a>
<div style="position: absolute;
right: 0px;
top: 570px;
height: 2px;
background-color:#ccc;
width: 174px;"></div>
<div style="position: absolute;
right: 0px;
top: 0px;
height: 2px;
background-color:#ccc;
width: 174px;"></div>
<div style="position: absolute;
right: 0px;
top: 230px;
height: 2px;
background-color:#ccc;
width: 174px;"></div>
<div id="social" style="z-index:102;position: absolute;
right: 0px;
height:35px;
top: 590px;">
<span class='st_facebook_custom'><img class="socialico rotmenu2"
src="https://cdn3.iconfinder.com/data/icons/free-social-icons/67/Untitled-16-24.png"></span>
<span class='st_twitter_custom'><img class="socialico rotmenu2"
src="https://cdn3.iconfinder.com/data/icons/free-social-icons/67/Untitled-15-24.png"></span>
<span class='st_googleplus_custom'><img class="socialico rotmenu2"
src="https://cdn3.iconfinder.com/data/icons/free-social-icons/67/Untitled-9-24.png"></span>
<span class='st_linkedin_custom'><img class="socialico rotmenu2"
src="https://cdn3.iconfinder.com/data/icons/free-social-icons/67/Untitled-11-24.png"></span>
<span class='st_email_custom'><img class="socialico rotmenu2"
src="https://cdn4.iconfinder.com/data/icons/app-custom-ui-1/48/Envelope-24.png"></span>
<a href="" download="" id="csvdownload"><span><img class="socialico rotmenu2"
src="https://cdn4.iconfinder.com/data/icons/app-custom-ui-1/48/Download-24.png"></span></a>
<span id="pngdownloadwrapper"><img class="socialico rotmenu2"
src="https://cdn4.iconfinder.com/data/icons/app-custom-ui-1/48/Camera-24.png"></span>
</div>
<a href="https://www.csaladen.es/doc/Denes_NETSET_process_diagram.pdf" target="_blank">
<img class="rotmenu" style="position: absolute;
right: 128px;
top: 155px;
height: 38px;
width: 38px; border:none" alt="NETSET process diagram" title="NETSET description" src="icon/desc.png" />
<div style="position: absolute;
right: 134px;
top: 200px;
height: 22px;
font-size:10px;
font-family: Arial;
text-align:center;
white-space: nowrap;
width: 40px;">description</div>
</a>
<a href="https://d3plus.org" target="_blank">
<img class="rotmenu" style="position: absolute;
right: 41px;
top: 155px;
height: 38px;
width: 38px;" alt="Written in Python, simulated in AnyLogic, visualized in D3plus"
title="Written in Python, simulated in AnyLogic, visualized in D3plus" src="icon/engine.png" />
<div style="position: absolute;
right: 41px;
top: 200px;
height: 22px;
font-size:10px;
font-family: Arial;
text-align:center;
white-space: nowrap;
width: 40px;">engine</div>
</a>
<a href="https://www.csaladen.es" target="_blank">
<img class="rotmenu" style="position: absolute;
right: 0px;
top: 155px;
height: 38px;
width: 38px;" alt="Denes Csala & Sgouris Sgouridis © 2016"
title="Denes Csala & Sgouris Sgouridis © 2016" src="icon/credit.png" />
<div style="position: absolute;
right: 0px;
top: 200px;
height: 22px;
font-size:10px;
font-family: Arial;
text-align:center;
white-space: nowrap;
width: 40px;" />credit</div></a>
<a href="#">
<img class="rotmenu" style="position: absolute;
right: 84px;
top: 155px;
height: 38px;
width: 38px;" alt="Data sources: EIA, BP, UNSD, WDI" title="Data sources: EIA, BP, UNSD, WDI"
src="icon/netset_data.png" />
<div style="position: absolute;
right: 84px;
top: 200px;
height: 22px;
font-size:10px;
font-family: Arial;
text-align:center;
white-space: nowrap;
width: 40px;">data</div>
</a>
<div style="position: absolute;
right: 60px;
top: 308px;
height: 22px;
font-size:12px;
font-family: Arial;
text-align:center;
width: 52px;" alt="Timeline" title="Timeline" onclick='show(5);'>Map</div>
<div style="position: absolute;
right: 0px;
top: 308px;
height: 22px;
font-size:12px;
font-family: Arial;
text-align:center;
width: 52px;" alt="Network" title="Network" onclick='show(6);'>Network</div>
<div style="position: absolute;
right: 122px;
top: 308px;
height: 22px;
font-size:12px;
font-family: Arial;
text-align:center;
width: 52px;" alt="Line Plot" title="Line Plot" onclick='show(4);'>Resource</div>
<div style="position: absolute;
right: 60px;
top: 393px;
height: 22px;
font-size:12px;
font-family: Arial;
text-align:center;
width: 52px;" alt="Timeline" title="Timeline" onclick='show(1);'>Timeline</div>
<div style="position: absolute;
right: 0px;
top: 393px;
height: 22px;
font-size:12px;
font-family: Arial;
text-align:center;
width: 52px;" alt="Treemap" title="Treemap" onclick='show(2);'>Treemap</div>
<div style="position: absolute;
right: 120px;
top: 393px;
height: 22px;
font-size:12px;
font-family: Arial;
text-align:center;
width: 52px;" alt="Line Plot" title="Line Plot" onclick='show(3);'>Line Plot</div>
<div style="position: absolute;
right: 60px;
top: 478px;
height: 22px;
font-size:12px;
font-family: Arial;
text-align:center;
width: 52px;" alt="Influence" title="Influence" onclick='show(7);'>Influence</div>
<div style="position: absolute;
right: -5px;
top: 515px;" alt="Select Country" title="Select Country" id="countrylist"></div>
</div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 100;" id="viz1" class="viz viz1"></div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 99;" id="viz2" class="viz viz2"></div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 99;" id="viz3" class="viz viz3"></div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 100;" id="viz4" class="viz viz4"></div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 99;" id="viz5" class="viz viz5"></div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 99;" id="viz6" class="viz viz6"></div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 99;" id="viz7" class="viz viz7"></div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 99;" id="viz8" class="viz viz8"></div>
<div style="position: fixed; opacity:0;
left: 5;
top: 5;
z-index: 99;" id="viz9" class="viz viz9"></div>
<div style="position: fixed; opacity:0;
left:0;
bottom:0;
margin-bottom:10px;
z-index: 101;" id="viz6drop" class="viz6"></div>
<div style="position: fixed; opacity:0;
left:0;
bottom:0;
margin-bottom:10px;
z-index: 101;" id="viz6drop2" class="viz6"></div>
<script>
// sample data array
var initcountry = 'United Kingdom';
var initcountrysave = initcountry;
var initviz = 1;
var sca = "linear";
var center = "+";
var scenario = "r5";
var start = "2000";
var end = "2100";
function sethash() {
scale = (sca == "linear") ? 0 : 1;
window.location.hash = "&viz_" + initviz + "&scale_" + scale + "&scenario_" + scenario + "&start_" + start + "&end_" + end + "&country_" + initcountry;
}
//hashing, startup, etc
var hash = window.location.hash;
if (hash == "") {
sethash();
}
else {
if (hash.indexOf("&country_") > -1) {
var cloc = hash.search("&country_");
var cdummy = hash.slice(cloc + 9)
var cloc = cdummy.search("&");
initcountry = (cloc > -1) ? cdummy.slice(0, cloc) : cdummy;
}
if (hash.indexOf("&viz") > -1) {
var cloc = hash.search("&viz_");
initviz = hash.slice(cloc + 5, cloc + 6)
}
if (hash.indexOf("&scale") > -1) {
var cloc = hash.search("&scale_");
scale = hash.slice(cloc + 7, cloc + 8)
}
if (hash.indexOf("&scenario") > -1) {
var cloc = hash.search("&scenario_");
scenario = hash.slice(cloc + 10, cloc + 12)
}
if (hash.indexOf("&start") > -1) {
var cloc = hash.search("&start_");
start = hash.slice(cloc + 7, cloc + 11)
}
if (hash.indexOf("&end") > -1) {
var cloc = hash.search("&end_");
end = hash.slice(cloc + 5, cloc + 9)
}
}
if (initcountry == "None") {
initcountry = initcountrysave;
}
initcountry = initcountry.replace(/%20/g, ' ');
sca = (scale == 1) ? "share" : "linear";
setTimeout(function () { d3.selectAll(".logo").style("opacity", 1) }, 1000)
var showd = [true, true, true, true, true, true, true, true, true];
var visualization = d3plus.viz().container("#viz1")
var visualization2 = d3plus.viz().container("#viz2")
var visualization3 = d3plus.viz().container("#viz3")
var visualization4 = d3plus.viz().container("#viz4")
var visualization5 = d3plus.viz().container("#viz5")
var visualization6 = d3plus.viz().container("#viz6")
var visualization7 = d3plus.viz().container("#viz7")
var visualization8 = d3plus.viz().container("#viz8")
var visualization9 = d3plus.viz().container("#viz9")
var viz6drop = d3plus.form().container("#viz6drop")
var load = function () { };
var load7 = function () { };
var network = function (y, v) { };
var ids = ["type", "country", "partner"];
var country7 = "json/77/impex_n_uk.json";
function show(a) {
initviz = a;
sethash();
d3.selectAll(".viz1").style("opacity", 0);
d3.selectAll(".viz2").style("opacity", 0);
d3.selectAll(".viz3").style("opacity", 0);
d3.selectAll(".viz4").style("opacity", 0);
d3.selectAll(".viz5").style("opacity", 0);
d3.selectAll(".viz6").style("opacity", 0);
d3.selectAll(".viz7").style("opacity", 0);
d3.selectAll(".viz8").style("opacity", 0);
d3.selectAll(".viz9").style("opacity", 0);
d3.selectAll(".viz1").style("z-index", 99);
d3.selectAll(".viz2").style("z-index", 99);
d3.selectAll(".viz3").style("z-index", 99);
d3.selectAll(".viz4").style("z-index", 99);
d3.selectAll(".viz5").style("z-index", 99);
d3.selectAll(".viz6").style("z-index", 99);
d3.selectAll(".viz7").style("z-index", 99);
d3.selectAll(".viz8").style("z-index", 99);
d3.selectAll(".viz9").style("z-index", 99);
d3.selectAll(".viz" + a).style("z-index", 100);
d3.selectAll(".viz" + a).style("opacity", 1);
if (showd[a - 1]) { //draw if on first clikc/load
load(initcountry, a);
showd[a - 1] = false;
}
}
//check if in dev mode and on local server
var masterpath = '';//((window.location.hostname=='localhost')
//?'https://localhost:7000/'
//:"https://dl.dropboxusercontent.com/u/531697/datarepo/"
//)
//+'netset/';
path = masterpath + "json/" + scenario + "/" //default
function getByName(arr, value) {
for (var i = 0, iLen = Object.keys(arr).length; i < iLen; i++) {
if (arr[Object.keys(arr)[i]] == value) return Object.keys(arr)[i];
}
}
JSZipUtils.getBinaryContent('json/res.zip', function (err, rawres) {
var zip = new JSZip(rawres);
var res = JSON.parse(zip.files['res.json'].asText());
d3.json('json/clrs.json', function (clrs) {
d3.json('json/isoico.json', function (isoico) {
d3.json('json/pop.json', function (pop) {
d3.json('json/isocountries.json', function (isocountries) {
d3.json('flags/isocolors.json', function (isocolors) { //colors with https://mkweb.bcgsc.ca/color-summarizer/?url=https://netset.csaladen.es/flags/'+i+'&precision=vlow&text=1&num_clusters=5
d3.json('json/isocountries2.json', function (isocountries2) {
d3.json('json/countries.json', function (countries) {
d3.json('json/labeler.json', function (labeler) {
d3.json('json/h2.json', function (h2) {
risocountries = [];//this is only used for the world map
Object.keys(isocountries).forEach(function (d) {
risocountries[isocountries[d]] = parseInt(d);
})
//corrections
risocountries["United States of America"] = 840;
isocountries[840] = "United States of America"
risocountries["Greenland"] = 304;
isocountries[304] = "Greenland";
risocountries["France"] = 250;
isocountries[250] = "France";
risocountries["Italy"] = 380;
isocountries[380] = "Italy";
risocountries["Norway"] = 578;
isocountries[578] = "Norway";
risocountries["Germany"] = 276;
isocountries[276] = "Germany";
risocountries["India"] = 356;
isocountries[356] = "India";
risocountries["Sudan"] = 729;
isocountries[729] = "Sudan";
risocountries["South Sudan"] = 728;
isocountries[728] = "South Sudan";
risocountries["Viet Nam"] = 704;
isocountries[704] = "Viet Nam";
risocountries["Yemen"] = 887;
isocountries[887] = "Yemen";
risocountries["Switzerland"] = 756;
isocountries[756] = "Switzerland";
risocountries["Panama"] = 591;
isocountries[591] = "Panama";
risocountries["Puerto Rico"] = 630;
isocountries[630] = "Puerto Rico";
risocountries["Serbia"] = 688;
isocountries[688] = "Serbia";
isoico["Greenland"] = "DK";
isoico["Puerto Rico"] = "US";
isoico["South Sudan"] = "ZZ";
isoico["Yemen"] = "YE";
var geodata = []; //construct geodata for map plotter
Object.keys(pop).forEach(function (d) {
Object.keys(pop[d]).forEach(function (e) {
geodata.push({ "year": e, "pop": pop[d][e], "country": d, "id": risocountries[d], "h2": 100 * h2[d] });
})
})
JSZipUtils.getBinaryContent(path + initcountry + '.zip', function (err, rawdata) {
var order = {
"coal": 300,
"oil": 270,
"gas": 240,
"biofuels": 180,
'nuclear': 210,
'hydro': 200,
'geo_other': 220,
'solar': 140,
'wind': 150,
'csp': 130,
'electricity': 160,
'grid': 160,
'Power-to-liquid': 170,
'storage': 190,
'balance': 110
}
var ucolor = {
"coal": d3.rgb(85, 20, 52),
"oil": d3.rgb(131, 13, 9),
"gas": d3.rgb(217, 20, 14),
"biofuels": d3.rgb(64, 185, 85),
'nuclear': d3.rgb(179, 0, 45),
'hydro': d3.rgb(202, 200, 46),
'geo_other': d3.rgb(106, 23, 9),
'solar': d3.rgb(251, 212, 31),
'wind': d3.rgb(112, 133, 16),
'csp': d3.rgb(254, 159, 28),
'electricity': d3.rgb(0, 140, 70),
'grid': d3.rgb(0, 140, 70),
'Power-to-liquid': d3.rgb(213, 9, 98),
'storage': d3.rgb(32, 32, 47),
'balance': d3.rgb(32, 32, 47)
}
var heatmap2 = [ucolor["csp"], ucolor["solar"], ucolor["wind"], ucolor["electricity"], ucolor["Power-to-liquid"], ucolor["biofuels"], ucolor["storage"], ucolor["hydro"], ucolor["nuclear"], ucolor["geo_other"], ucolor["gas"], ucolor["oil"], ucolor["coal"]];
var heatmap3 = [
"#006837",
"#31a354",
"#78c679",
"#c2e699",
"#fed98e",
"#fe9929",
"#d95f0e",
"#993404",
"#993404",
"#980043",
"#980043",
"#dd1c77",
"#dd1c77",
"#dd1c77",
"#df65b0",
"#df65b0",
"#df65b0"];
var heatmap = [
"#006837",
"#ffc926",
"#d9006c",
"#222222",
"#222222",
"#777777",
"#bbbbbb",
"#eeeeee",
"#ffffff"
];
var q1color = {
"Production": d3.rgb(112, 133, 16),
"Consumption": d3.rgb(179, 0, 45),
"Import": d3.rgb(202, 200, 46),
"Export": d3.rgb(85, 20, 52),
'Re-Import': d3.rgb(251, 212, 31),
'Re-Export': d3.rgb(213, 9, 98)
}
var gcolor = {
"fossil fuels": d3.rgb(131, 13, 9),
"scale limited": d3.rgb(202, 200, 46),
'solar': d3.rgb(251, 212, 31),
'renewables': d3.rgb(254, 159, 28),
"traded & stored": d3.rgb(0, 140, 70)
}
var group = {
"coal": "fossil fuels",
"oil": "fossil fuels",
"gas": "fossil fuels",
"biofuels": "scale limited",
'nuclear': "scale limited",
'hydro': "scale limited",
'geo_other': "renewables",
'solar': "renewables",
'wind': "renewables",
'balance': "renewables",
'csp': "renewables",
"electricity": "traded & stored",
'Power-to-liquid': "traded & stored"
}
var tradeway = { "ptl": "Power-to-liquid", "grid": "grid" }
var by = { "Import": "from", "Export": "to", "Re-Import": "from", "Re-Export": "to", "Production": "by", "Consumption": "by" }
function extend(rawdata) {
var zip = new JSZip(rawdata);
var data = JSON.parse(zip.files['data.json'].asText());
//prefilter - now handled in Python
//data.forEach(function(d) {d["s"]=Math.abs(d["s"])});
data = data
.filter(function (d) { return d["s"] > 1 })
.filter(function (d) { return d["t"] > 1964 })
.filter(function (d) { return d["t"] < 2101 })
data.forEach(function (d) {
//set q2 level country flags and dominant colors
//set flow direction
if (d["q1"] == "pp") d["q1"] = "Production";
if (d["q1"] == "cc") d["q1"] = "Consumption";
if (d["q2"] == 999) d["q2"] = initcountry
else d["q2"] = isocountries[d["q2"]];
if (d["q2"] == initcountry) { //self-trade
if (d["q1"] == "Import") d["q1"] = "Production";
if (d["q1"] == "Export") d["q1"] = "Consumption";
}
//bottom-most level
d["q3"] = d["u"] + "_";
//separate trade fuel from source
if (d["u"].search('_') > 0) {
if (d["u"].search('geo_') < 0) {
//console.log(d["u"])
if (d["q2"] != initcountry) {
d["u"] = tradeway[d["u"].slice(0, d["u"].search('_'))]
} else {
d["u"] = d["u"].slice(0, d["u"].search(' '))
}
}
d["q3"] = d["q3"].slice(d["q3"].search('_') + 1)
}
d["q3"] = d["q3"].slice(0, d["q3"].search('_'))
//add genders and population (prod/cons)
d["s+"] = (d["g"] == "f") ? d["s"] : -d["s"];
d["s"] = Math.abs(d["s+"])
d[d["g"]] = d["s"];
d[d["g"] + "+"] = d["s+"];
//fix category mismatches
if (d["u"] == "pv") d["u"] = "solar";
if (d["u"] == "grid_win") d["u"] = "electricity";
if (d["u"] == "grid_cs") d["u"] = "electricity";
if (d["u"] == "grid_sola") d["u"] = "electricity";
if (d["u"] == "ptl_win") d["u"] = "Power-to-liquid";
if (d["u"] == "ptl_sola") d["u"] = 'Power-to-liquid';
if (d["u"] == "ptl_cs") d["u"] = 'Power-to-liquid';
if (d["u"] == "ptl_biofuel") d["u"] = 'Power-to-liquid';
if (d["u"] == "ptl_nuclea") d["u"] = 'Power-to-liquid';
if (d["u"] == "ptl_hydr") d["u"] = 'Power-to-liquid';
if (d["u"] == "ptl_coa") d["u"] = 'Power-to-liquid';
if (d["u"] == "ptl_geo_other") d["u"] = 'Power-to-liquid';
if (d["q3"] == "pv") d["q3"] = "solar";
if (d["u"] == "electricity") {
d["u"] = "grid";
d["q3"] = "electricity";
}
//set colors and icons
d["ucolor"] = ucolor[d["u"]];
d["group"] = group[d["u"]];
d["uicon"] = "img/" + d["u"] + ".png";
if (initcountry in pop)
if (d["t"] in pop[initcountry]) {
d["ps"] = d["s"] * 1000000000000.0 / 8760 / pop[initcountry][d["t"]]; //per capita, unit conversion from TWh to Wh
d["p" + d["g"]] = d["ps"];
d["ps+"] = d["s+"] * 1000000000000.0 / 8760 / pop[initcountry][d["t"]]; //per capita, unit conversion to yearly avg power
d["p" + d["g"] + "+"] = d["ps+"];
} else console.log("No population data for:", initcountry, d["t"]);
//setdisplay order
//d["order"]=parseInt((d["g"]=="f")?2000+(400-order[d["u"]]):2000+(400-order[d["u"]])); //set both to a for next to each other ordering
//d["order2"]=parseInt((d["g"]=="f")?2000+(400-order[d["u"]]):1000+(order[d["u"]])); //set both to
});
if (!(initcountry in pop)) console.log("No population data for:", initcountry, "all years");
return data
}
function cap1(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function textformatter(text, params) {
if (text.indexOf("&group") > -1) text = text.slice(9);
if (Object.keys(labeler).indexOf(text) > -1) {
return labeler[text];
}
if (text.indexOf('_uppercase') > -1) {
return text.slice(0, text.indexOf('_uppercase')).toUpperCase();
}
if (text === "t") {
return "Year";
}
if (text === "pv") {
return "Photovoltaic";
}
if (text === "biofuels") {
return "Bioenergy";
}
if (text === "electricity") {
return "Traded Electricity";
}
if (text === "grid") {
return "Traded Electricity";
}
if (text === "csp") {
return "Solar Thermal";
}
if (text === "solar") {
return "Photovoltaic";
}
else if (text === "s") {
return "Energy";
}
else if (text === "s+") {
return "Energy";
}
else if (text === "f") {
return "Inflow";
}
else if (text === "m") {
return "Outflow";
}
else if (text === "f+") {
return "Inflow";
}
else if (text === "m+") {
return "Outflow";
}
else if (text === "pf") {
return "Power / Capita";
}
else if (text === "pm") {
return "Power / Capita";
}
else if (text === "ps") {
return "Power / Capita";
}
else if (text === "pf+") {
return "Power / Capita";
}
else if (text === "pm+") {
return "Power / Capita";
}
else if (text === "ps+") {
return "Power / Capita";
}
else if (text === "geo_other") {
return "Other";
}
else if (text === "pop") {
return "Population";
}
else if (text === "h2") {
return "Power-to-liquid";
}
else {
return d3plus.string.title(text, params);
}
};
function numberformatter(number, params) {
number = Math.abs(number);
var formatted = d3plus.number.format(number, params);
return formatted// + ((val=="")?" TWh":" W");
};
function vfunc(val, gen, center) {
return val + gen + ((sca == "share") ? "" : center);
}
data = extend(rawdata);
var countrylist = [];
countries.sort().forEach(function (d, i) {
var dummy = { "country": d };
countrylist.push(dummy);
});
var val = "";
var gen = "s";
var val3 = "";
var gen3 = "s+";
var val2 = "";
var gen2 = "s";
var sub = { "m": "Outflow", "f": "Inflow" };
var title = { "font": { "size": 20 } };
var font = { "family": "Arial", "size": 15 };
var countrydrop = d3plus.form()
.data(countrylist)
.container("#countrylist")
.font({ "family": "Arial", "size": 15, "align": "center", "secondary": { "family": "Arial" } })
.id("country")
.width(174)
.text("country")
.focus(initcountry, function (d) {
showd = [true, true, true, true, true, true, true, true, true];
showd[initviz - 1] = false;
load(d, initviz);
})
.type("drop")
.draw()
var scenariolist = [{ "id": "00", "name": "Raw (00)" },
{ "id": "10", "name": "Raw+Phaseout (10)" },
{ "id": "01", "name": "Raw+Balance (01)" },
{ "id": "0a", "name": "Raw [new] (0a)" },
{ "id": "0b", "name": "Base Impex (0b)" },
{ "id": "02", "name": "Infeasible (02)" },
{ "id": "53", "name": "Long-life (53)" },
{ "id": "55", "name": "Base low SI (55)" },
{ "id": "56", "name": "Base (56)" },
{ "id": "61", "name": "Race to the bottom 1 (61)" },
{ "id": "62", "name": "Race to the bottom 2 (62)" },
{ "id": "63", "name": "Race to the bottom 3 (63)" },
{ "id": "71", "name": "Old lowest SI (71)" },
{ "id": "72", "name": "Old low SI (72)" },
{ "id": "74", "name": "Old medium SI (74)" },
{ "id": "79", "name": "Old high SI (79)" },
{ "id": "q5", "name": "Low SI Mid PF (q5)" },