-
Notifications
You must be signed in to change notification settings - Fork 1
/
h9n2_AR.html
385 lines (318 loc) · 11 KB
/
h9n2_AR.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
<!DOCTYPE html>
<!-- basic drawing capability taken from url=(0040)http://bl.ocks.org/mbostock/raw/2429963/ -->
<!-- some tree stuff inspired by https://gist.github.com/kueda/1036776 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><meta charset="utf-8">
<title>pandemix</title>
<!-- <link rel="stylesheet" href="css/bootstrap-responsive.css"> -->
<link rel="stylesheet" type="text/css" href="css/h9n2.css">
<link rel="stylesheet" type="text/css" href="css/pandemix.css">
<link rel="stylesheet" type="text/css" href="css/leaflet.css" />
<!-- <link rel="stylesheet" media="screen" href="css/bootstrap.css"> -->
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
<!-- <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> -->
<script src="javascript/jquery-2.0.2.js"></script>
<script src="javascript/d3.v3.min.js"></script>
<script src="javascript/crossfilter.min.js"></script>
<script src="javascript/leaflet.js"></script>
<script src="javascript/pandemix.js"></script>
<script src="javascript/timePanel.js"></script>
<script src="javascript/mapPanel.js"></script>
<script src="javascript/treePanel.js"></script>
<script src="javascript/tablePanel.js"></script>
<script src="javascript/traitPanel.js"></script>
<script src="javascript/traitSelectionPanel.js"></script>
<script src="javascript/legendPanel.js"></script>
<script src="javascript/regionOutlineMapLayer.js"></script>
<script src="javascript/locationMapLayer.js"></script>
<script src="javascript/virusParticleMapLayer.js"></script>
<script src="javascript/bubbleChartMapLayer.js"></script>
<script src="javascript/bubbleTransMapLayer.js"></script>
<script src="javascript/treeMapLayer.js"></script>
<script src="javascript/collabsible.js"></script>
<style type="text/css">
body {
font-family: Helvetica,Arial,sans-serif;
font-weight: 200;
font-size: 12px;
width: 2000px;
}
#playPause {
margin-right: 10px;
}
.legendPanel {
width: 200px;
height: 500px;
border: none;
}
#map {
width: 800px;
height: 500px;
}
.treePanel.svgBox {
width: 450px;
height: 500px;
font-size: 6px;
}
</style>
<style type="text/css">
/* styling for leaflet map */
.leaflet-control-zoom {
box-shadow: 0 0px;
background: white;
background: rgba(255,255,255,0.8);
border-style: solid;
border-width: 1px;
border-color: #CCCCCC;
border-radius: 5px;
}
</style>
<style type="text/css">
/* styling for collapsible panels; */
.panel, .panelcollapsed
{
margin-top: 5px;
/*border: 1px solid #999;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;*/
}
/* panel heading */
.panel h2, .panelcollapsed h2
{
font-size: 14px;
font-weight: 300;
margin: 0px;
padding: 4px;
padding-left: 20px;
/* background: #EEEEEE; */
background-image:url('img/arrow-up.gif');
background-repeat:no-repeat;
background-position: left center;
border-top: 1px solid #CCC;
/* border-bottom: 1px solid #CCC;
border-right: 1px solid #CCC;
border-left: 1px solid #CCC;
-moz-border-radius: 3px;
-webkit-border-radius: 3px;
*/
}
/* panel heading on rollover */
.panel h2:hover, .panelcollapsed h2:hover { background-color: #F5F7F9; }
/* heading of a collapsed panel */
.panelcollapsed h2
{
/* background: #DDDDDD; */
background-image:url('img/arrow-dn.gif');
background-repeat:no-repeat;
background-position: left center;
border-color: #CCC;
}
/* panel content - do not set borders or paddings */
.panelcontent
{
background: #FFFFFF;
overflow: hidden;
}
/* collapsed panel content */
.panelcollapsed .panelcontent { display: none; }
</style>
</head>
<body>
<h3>H9N2 <span class="date-calendar"></span></h3>
<div>
<div id="playPause" style="display: inline-block"></div>
<div id="globalTime" style="display: inline-block"></div>
</div>
<div class="panel">
<h2>Map: <span class="date-calendar"></span></h2>
<div class="panelcontent">
<div>
<div id="map" style="display: inline-block"></div>
<div id="legend" style="display: inline-block; vertical-align:top" ></div>
</div>
<button id="map-reset">Reset Map</button>
<button id="show-location">Locations</button>
<button id="show-HA">HA subtype</button>
<button id="show-NA">NA subtype</button>
<button id="show-segment">Segment</button>
<button id="save-svg">Save SVG</button>
</div>
</div>
<div class="panel" style="margin-top: 5px">
<h2>Controls</h2>
<div class="panelcontent">
<div id="legend"></div>
<div>
<div id="search" style="display: inline"></div>
<div id="color" style="display: inline"></div>
` </div>
</div>
</div>
<div>
<div id="zoom" style="margin-top: 15px; ddisplay: inline-block; vertical-align:top"></div>
<div style="margin-top: 15px; display: inline-block">
<div class="panel" style="display: inline-block">
<h2>PB2 Tree</h2>
<div class="panelcontent">
<div>
<div id="tree1"></div>
</div>
</div>
</div>
<div class="panel" style="margin-top: 5px; display: inline-block">
<h2>PB1 Tree</h2>
<div class="panelcontent">
<div>
<div id="tree2"></div>
</div>
</div>
</div>
</div>
<div style="margin-top: 5px; display: block">
<div class="panel" style="margin-top: 5px; display: inline-block">
<h2>PA Tree</h2>
<div class="panelcontent">
<div>
<div id="tree3"></div>
</div>
</div>
</div>
<div class="panel" style="display: inline-block">
<h2>NP Tree</h2>
<div class="panelcontent">
<div>
<div id="tree4"></div>
</div>
</div>
</div>
</div>
<div style="margin-top: 5px; display: block">
<div class="panel" style="margin-top: 5px; display: inline-block">
<h2>MP Tree</h2>
<div class="panelcontent">
<div>
<div id="tree5"></div>
</div>
</div>
</div>
<div class="panel" style="margin-top: 5px; display: inline-block">
<h2>NS Tree</h2>
<div class="panelcontent">
<div>
<div id="tree6"></div>
</div>
</div>
</div>
</div>
</div>
<script>
//script wrapped in a function to avoid polluting namespace
(function() {
var i,
contourFile = "data/reducedGeography.json",
centroidFile = "data/H9N2_locations.csv"
tileSource = "http://{s}.tile.cloudmade.com/1a1b06b230af4efdbb989ea99e9841af/998/256/{z}/{x}/{y}.png",
inputFiles = ["data/H9N2 Trees/H9N2.PB2.json",
"data/H9N2 Trees/H9N2.PB1.json",
"data/H9N2 Trees/H9N2.PA.json",
"data/H9N2 Trees/H9N2.NP.json",
"data/H9N2 Trees/H9N2.MP.json",
"data/H9N2 Trees/H9N2.NS.json"
];
var mapPanel = new pandemix.MapPanel;
mapPanel.placePanel({target: "map", initCoords: [34, 104], initZoom: 4})
.addLayer({layerType: pandemix.map.regionOutlineLayer, name: "Regions"})
//.addTileLayer(tileSource)
.loadContours(contourFile)
.loadCentroids(centroidFile)
.addInfoDisplay(function(d) {return "<h4>" + d.location + "</h4>" + d.treeName + " - " + d.number})
.addLayer({layerType: pandemix.map.locationLayer, name: "Locations", displayedProperty: "location", unitRadius: 0.5, minRadius: 1, maxRadius: 50});
$( "#map-reset" ).click(function() {
mapPanel.getMap().setView([34, 104], 4);
});
$( "#show-location" ).click(function() {
pandemix.selectTrait("location");
});
$( "#show-HA" ).click(function() {
pandemix.selectTrait("Hx");
});
$( "#show-NA" ).click(function() {
pandemix.selectTrait("Nx");
});
$( "#show-segment" ).click(function() {
pandemix.selectTrait("Tree");
});
$( "#save-svg" ).click(function() {
writeDownloadLink();
});
pandemix.panels.push(mapPanel);
pandemix.addSearchBox({target: "#search"});
pandemix.addColorPicker({target: "#color"});
pandemix.addGlobalZoomButton({target: "#zoom", zoomAmount: 1});
//var traitSelectionPanel = new pandemix.TraitSelectionPanel;
//traitSelectionPanel.placePanel({target: "#traitSelection"});
var legendPanel = new pandemix.LegendPanel;
legendPanel.placePanel({target: "#legend"});
var timePanel = new pandemix.TimePanel;
timePanel.placePanel({target: "#globalTime"});
pandemix.addPlayPauseButton({target: "#playPause", updateInterval: 200, updateStep: 10});
pandemix.initializeCrossfilter();
//read each input file and draw the tree in its own div
for (i = 0; i < inputFiles.length; i += 1) {
var f = inputFiles[i];
var treePanel = new pandemix.TreePanel;
treePanel.placePanel("#tree" + (i + 1));
treePanel.initializePanelData({file: f, color: pandemix.getHSBColor(i, inputFiles.length)});
mapPanel.addLayer({layerType: pandemix.map.treeLayer, treePanel: treePanel, name: "Tree", color: treePanel.getColor()})
}
mapPanel.addLayer({layerType: pandemix.map.bubbleTransLayer, name: "Bubble transitions", radius: 1})
.addLayer({layerType: pandemix.map.bubbleChartLayer, name: "Bubble chart", unitRadius: 1});
pandemix.when(function() {
return pandemix.panelsLoaded("treePanel");
}, function() {
pandemix.selectTrait("Tree");
}, 100);
})();
function show_svg_code()
{
// Get the d3js SVG element
var tmp = document.getElementById("tree1");
var svg = tmp.getElementsByTagName("svg")[0];
// Extract the data as SVG text string
var svg_xml = (new XMLSerializer).serializeToString(svg);
window.open().document.write(svg_xml);
$("svg").attr({ version: '1.1' , xmlns:"http://www.w3.org/2000/svg"});
}
function writeDownloadLink(){
var tmp = document.getElementById("tree1");
var svg = tmp.getElementsByTagName("svg")[0];
// Extract the data as SVG text string
var svg_xml = (new XMLSerializer).serializeToString(svg);
window.open().document.write(svg_xml);
var html = d3.select("svg")
.attr("title", "test2")
.attr("version", 1.1)
.attr("xmlns", "http://www.w3.org/2000/svg")
.node().parentNode.innerHTML;
d3.select("body").append("div")
.attr("id", "download")
.style("top", event.clientY+20+"px")
.style("left", event.clientX+"px")
.html("Right-click on this preview and choose Save as<br />Left-Click to dismiss<br />")
.append("img")
.attr("src", "data:image/svg+xml;base64,"+ btoa(html));
d3.select("#download")
.on("click", function(){
if(event.button == 0){
d3.select(this).transition()
.style("opacity", 0)
.remove();
}
})
.transition()
.duration(500)
.style("opacity", 1);
};
</script>
</body></html>