-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotD3.html
52 lines (50 loc) · 1.51 KB
/
plotD3.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Concentration time series plotting</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
.existing {color: blue;}
.new {color: green;}
</style>
</head>
<body>
<h1>Gene concentrations</h1>
<!--<p> previous paragraph</p>-->
<script type="text/javascript">
//loading a csv file
d3.csv("evolved1.csv", function(data) {
//Gene1
//Width and height
var w = 800;
var h = 200;
var barPadding = 1;
//Create SVG element
var svg4 = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
//Bind data
var rect4 = svg4.selectAll("rect")
.data(data);
//For every new created rectangle visualize
rect4.enter()
.append("rect")
.attr("x", function(d,i) {return i+1;})
.attr("y", function(d) {return h-(100+80*d.gene4);})
.attr("width", function(d) {return w/data.length;})
.attr("height", function(d,i) {return 100+80*d.gene4;})
.style("fill",function(d,i) {
if (d.gene4 > 0) {
return "#7bff00";
}
else {
return "#0562f9";
}
});
}); //end of csv method
</script>
</body>
</html>