-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdna.html
More file actions
71 lines (61 loc) · 1.74 KB
/
dna.html
File metadata and controls
71 lines (61 loc) · 1.74 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>DNA</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.js"></script>
<script src="dat.js"></script>
</head>
<body>
<script>
var margin = {top: 20, right: 20, bottom: 30, left: 40},
width = 2000 - margin.left - margin.right,
height = 3000 - margin.top - margin.bottom;
var red = "#E74C3C",
green = "#1ABC9C",
blue = "#3498DB",
black = "#7F8C8D";
var color = {A: green, C: blue, T: red, G: black};
var dirs = {A: "up", C: "down", T: "left", G: "right"};
var sequence = "AATTCCGGACTGATCGTGCA"
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.style("background-color", "#2C3E50");
var prevX = 70;
var prevY = height - 10;
var xyChange = 10;
var circs = svg.selectAll()
.data(dat)
.enter().append("circle")
.attr("cy", function(d, i) {
if(dirs[d] == "up") {
newY = prevY + xyChange;
prevY = newY;
return newY;
}
else if(dirs[d] == "down") {
newY = prevY - xyChange;
prevY = newY;
return newY;
}
else { return prevY }
}) // y center pos
.attr("cx", function(d, i) {
if (dirs[d] == "right") {
newX = prevX + xyChange;
prevX = newX;
return newX
}
else if (dirs[d] == "left") {
newX = prevX - xyChange;
prevX = newX;
return newX
}
else { return prevX }
return i * 8; }) //x center pos
.attr("r", function(d, i) { return 4; }) // radius
.style("fill", function(d) { return color[d]});
</script>
</body>
</html>