Skip to content

Commit 76789dd

Browse files
committed
First spike
0 parents  commit 76789dd

File tree

7 files changed

+1209
-0
lines changed

7 files changed

+1209
-0
lines changed

LICENCE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Please note that the following files have separate licences:
2+
1. All files in the ext directory
3+
4+
Where not otherwise covered by separate copyright, this source code is Copyright Thomas Counsell (c) 2010, 2011.
5+
6+
Where not otherwise covered by a separate licence, this source code is distributed under the MIT licence: http://www.opensource.org/licenses/mit-license.php
7+
8+
Permission is hereby granted, free of charge, to any person obtaining a copy
9+
of this software and associated documentation files (the "Software"), to deal
10+
in the Software without restriction, including without limitation the rights
11+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
copies of the Software, and to permit persons to whom the Software is
13+
furnished to do so, subject to the following conditions:
14+
15+
The above copyright notice and this permission notice shall be included in
16+
all copies or substantial portions of the Software.
17+
18+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
THE SOFTWARE.

README.txt

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
JAVASCRIPT SANKEY DIAGRAMS
2+
A javascript library for drawing Sankey diagrams.
3+
4+
DEPENDENCIES
5+
raphael.js
6+
jquery.js (for the examples, not for the library itself)
7+
8+
USAGE
9+
10+
For the moment, see files in the examples folder
11+
12+
HACKING
13+
14+
The javascript is written in Coffescript in the src directory.
15+
16+
The canonical code is at:
17+
http://github.com/tamc/sankey
18+
19+
Please submit bug reports to:
20+
http://github.com/tamc/sankey/issues
21+
22+
Please submit patches to:
23+
http://github.com/tamc/sankey/pullrequests
24+
25+

examples/alpha.html

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
3+
<head>
4+
<meta content='text/html; charset=utf-8' http-equiv='Content-Type' />
5+
<title>Sankey Javascript Demo: Spread effort 2050 Pathway</title>
6+
<script src="../ext/raphael.js" type="text/javascript"></script>
7+
<script src="../ext/jquery.js" type="text/javascript"></script>
8+
<script src="../js/sankey.js" type="text/javascript"></script>
9+
</head>
10+
<body>
11+
<script type='text/javascript'>
12+
$(document).ready(function() {
13+
var raw_data = [["Coal reserves",0.0,"Coal"],["Coal imports",0.0,"Coal"],["Oil reserves",0.0,"Oil"],["Oil imports",0.0,"Oil"],["Gas reserves",0.0,"Ngas"],["Gas imports",0.0,"Ngas"],["UK land based bioenergy",0.0,"Bio-conversion"],["Marine algae",0.0,"Bio-conversion"],["Agricultural 'waste'",0.0,"Bio-conversion"],["Other waste",0.0,"Bio-conversion"],["Other waste",0.0,"Solid"],["Biomass imports",0.0,"Solid"],["Biofuel imports",0.0,"Liquid"],["Coal",0.0,"Solid"],["Oil",0.0,"Liquid"],["Ngas",0.0,"Gas"],["Solar",0.0,"Solar PV"],["Solar PV",0.0,"Electricity grid"],["Solar",0.0,"Solar Thermal"],[0.0,0.0,0.0],["Bio-conversion",0.0,"Solid"],["Bio-conversion",0.0,"Liquid"],["Bio-conversion",0.0,"Gas"],["Bio-conversion",0.0,"Losses"],["Solid",0.0,"Over generation / exports"],["Liquid",0.0,"Over generation / exports"],["Gas",0.0,"Over generation / exports"],["Solid",0.0,"Thermal generation"],["Liquid",0.0,"Thermal generation"],["Gas",0.0,"Thermal generation"],["Nuclear",0.0,"Thermal generation"],["Thermal generation",0.0,"District heating"],["Thermal generation",0.0,"Electricity grid"],["Thermal generation",0.0,"Losses"],["Solid",0.0,"CHP"],["Liquid",0.0,"CHP"],["Gas",0.0,"CHP"],["CHP",0.0,"Electricity grid"],["CHP",0.0,"Losses"],["Electricity imports",0.0,"Electricity grid"],["Wind",0.0,"Electricity grid"],["Tidal",0.0,"Electricity grid"],["Wave",0.0,"Electricity grid"],["Geothermal",0.0,"Electricity grid"],["Hydro",0.0,"Electricity grid"],["Electricity grid",0.0,"H2 conversion"],["Electricity grid",0.0,"Over generation / exports"],["Electricity grid",0.0,"Losses"],["Gas",0.0,"H2 conversion"],["H2 conversion",0.0,"H2"],["H2 conversion",0.0,"Losses"],["Solar Thermal",0.0,"Heating and cooling - homes"],["H2",0.0,"Road transport"],["Pumped heat",0.0,"Heating and cooling - homes"],["Pumped heat",0.0,"Heating and cooling - commercial"],["CHP",0.0,"Heating and cooling - homes"],["CHP",0.0,"Heating and cooling - commercial"],["District heating",0.0,"Heating and cooling - homes"],["District heating",0.0,"Heating and cooling - commercial"],["District heating",0.0,"Industry"],["District heating",0.0,"Losses"],["Electricity grid",0.0,"Heating and cooling - homes"],["Solid",0.0,"Heating and cooling - homes"],["Liquid",0.0,"Heating and cooling - homes"],["Gas",0.0,"Heating and cooling - homes"],["Electricity grid",0.0,"Heating and cooling - commercial"],["Solid",0.0,"Heating and cooling - commercial"],["Liquid",0.0,"Heating and cooling - commercial"],["Gas",0.0,"Heating and cooling - commercial"],["Electricity grid",0.0,"Lighting & appliances - homes"],["Gas",0.0,"Lighting & appliances - homes"],["Electricity grid",0.0,"Lighting & appliances - commercial"],["Gas",0.0,"Lighting & appliances - commercial"],["Electricity grid",0.0,"Industry"],["Solid",0.0,"Industry"],["Liquid",0.0,"Industry"],["Gas",0.0,"Industry"],["Electricity grid",0.0,"Agriculture"],["Solid",0.0,"Agriculture"],["Liquid",0.0,"Agriculture"],["Gas",0.0,"Agriculture"],["Electricity grid",0.0,"Road transport"],["Liquid",0.0,"Road transport"],["Electricity grid",0.0,"Rail transport"],["Liquid",0.0,"Rail transport"],["Liquid",0.0,"Domestic aviation"],["Liquid",0.0,"National navigation"],["Liquid",0.0,"International aviation"],["Liquid",0.0,"International shipping"],["Electricity grid",0.0,"Geosequestration"],["Gas",0.0,"Losses"]];
14+
sankey = new Sankey();
15+
sankey.setData(raw_data);
16+
sankey.stack(0,[
17+
"Pumped heat",
18+
"Solar",
19+
"Wind",
20+
"Tidal",
21+
"Wave",
22+
"Geothermal",
23+
"Hydro",
24+
"Electricity imports",
25+
"Nuclear",
26+
"Coal reserves",
27+
"Coal imports",
28+
"Biomass imports",
29+
"Oil reserves",
30+
"Oil imports",
31+
"Biofuel imports",
32+
"Gas reserves",
33+
"Gas imports",
34+
"UK land based bioenergy",
35+
"Agricultural 'waste'",
36+
"Other waste",
37+
"Marine algae"
38+
]);
39+
40+
sankey.stack(1,["Coal"],sankey.boxes["Coal reserves"].y);
41+
sankey.stack(1,["Oil"],sankey.boxes["Oil reserves"].y);
42+
sankey.stack(1,["Ngas"],sankey.boxes["Gas reserves"].y);
43+
sankey.stack(1,["Bio-conversion"],sankey.boxes["UK land based bioenergy"].y);
44+
45+
sankey.stack(2,["Solar Thermal", "Solar PV"],sankey.boxes["Solar"].y);
46+
sankey.stack(2,[
47+
"Solid",
48+
"Liquid",
49+
"Gas"
50+
],sankey.boxes["Coal"].y);
51+
52+
sankey.stack(3,[
53+
"Thermal generation",
54+
"CHP"
55+
],sankey.boxes["Nuclear"].y);
56+
57+
sankey.stack(4,["Electricity grid","District heating"],sankey.boxes["Wind"].y);
58+
59+
sankey.stack(5,["H2 conversion"],sankey.boxes["Electricity grid"].y);
60+
61+
sankey.stack(6,["H2"],sankey.boxes["H2 conversion"].y);
62+
63+
sankey.stack(7,[
64+
"Heating and cooling - homes",
65+
"Heating and cooling - commercial",
66+
"Lighting & appliances - homes",
67+
"Lighting & appliances - commercial",
68+
"Industry",
69+
"Road transport",
70+
"Rail transport",
71+
"Domestic aviation",
72+
"International aviation",
73+
"National navigation",
74+
"International shipping",
75+
"Agriculture",
76+
"Geosequestration",
77+
"Over generation / exports",
78+
//"Exports",
79+
"Losses"
80+
]);
81+
82+
// Nudge
83+
sankey.boxes["Losses"].y = (sankey.boxes["Marine algae"].b() - sankey.boxes["Losses"].size());
84+
// sankey.boxes["Exports"].y = (sankey.boxes["Losses"].y - sankey.boxes["Exports"].size() - y_space);
85+
// sankey.boxes["Over generation / exports"].y = (sankey.boxes["Exports"].y - sankey.boxes["Over generation / exports"].size() - y_space);
86+
87+
// Colours
88+
sankey.setColors({
89+
"Coal reserves":"#8F6F38",
90+
"Coal":"#8F6F38",
91+
"Coal imports":"#8F6F38",
92+
93+
"Oil reserves":"#A99268",
94+
"Oil":"#A99268",
95+
"Oil imports":"#A99268",
96+
97+
"Gas reserves":"#DDD4C4",
98+
"Ngas":"#DDD4C4",
99+
"Gas imports":"#DDD4C4",
100+
101+
"Solar":"#F6FF00",
102+
"Solar Thermal":"#F6FF00",
103+
"Solar PV":"#F6FF00",
104+
105+
"UK land based bioenergy":"#30FF00",
106+
"Bio-conversion":"#30FF00",
107+
"Marine algae":"#30FF00",
108+
"Agricultural 'waste'":"#30FF00",
109+
"Other waste":"#30FF00",
110+
"Biomass imports":"#30FF00",
111+
"Biofuel imports":"#30FF00",
112+
113+
"Solid":"#557731",
114+
"Liquid":"#7D9763",
115+
"Gas":"#BCC2AD",
116+
117+
"Electricity grid":"#0000FF",
118+
"Thermal generation":"#0000FF",
119+
"CHP":"#FF0000",
120+
"Nuclear":"#E2ABDB",
121+
122+
"District heating":"#FF0000",
123+
"Pumped heat":"#FF0000",
124+
"Useful district heat":"#FF0000",
125+
"CHP Heat":"#FF0000",
126+
127+
128+
"Electricity imports":"#0000FF",
129+
"Wind":"#C7E7E6",
130+
"Tidal":"#C7E7E6",
131+
"Wave":"#C7E7E6",
132+
"Geothermal":"#C7E7E6",
133+
"Hydro":"#C7E7E6",
134+
135+
"H2 conversion":"#FF6FCF",
136+
"Final electricity":"#0000FF",
137+
"Over generation / exports":"#0000FF",
138+
"H2":"#FF6FCF"
139+
});
140+
141+
142+
// Add the emissions
143+
// sankey.boxes["Thermal generation"].ghg = 100;
144+
// sankey.boxes["CHP"].ghg = 10;
145+
// sankey.boxes["UK land based bioenergy"].ghg = -100;
146+
// sankey.boxes["Heating and cooling - homes"].ghg = 20;
147+
148+
// Fix some of the colours
149+
sankey.recolour(sankey.boxes["Losses"].left_lines,"#AAAAAA");
150+
sankey.recolour(sankey.boxes["District heating"].left_lines,"#FF0000");
151+
sankey.recolour(sankey.boxes["Electricity grid"].left_lines,"#0000FF");
152+
153+
sankey.draw();
154+
});
155+
156+
</script>
157+
<div id='sankey'>
158+
&nbsp;
159+
</div>
160+
</body>
161+
</html>

0 commit comments

Comments
 (0)