Skip to content

Instantly share code, notes, and snippets.

@scampbell2434
Last active February 1, 2018 16:51
Show Gist options
  • Save scampbell2434/d5d81c51aee7fcb7bc48a5f428b732d6 to your computer and use it in GitHub Desktop.
Save scampbell2434/d5d81c51aee7fcb7bc48a5f428b732d6 to your computer and use it in GitHub Desktop.
french 3
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500)
var gene_Datateach = [{"name":"Gene1","start":50,"end":105, "DNA_sequence":"ACGCTAAGGCTATTA","direction":"forward","function":"function1","fill":"orange","y":100},
{"name":"Gene2","start":125,"end":200, "DNA_sequence":"ATAGCCATGCAATGCCC","direction":"forward","function":"function2","fill":"green","y":100},
{"name":"Gene4", "start":250, "end":432, "DNA_sequence": "CTTAGAACCGTTACGTAC","direction":"forward","function":"function4","fill":"red","y":200},
{"name":"Gene3", "start":159,"end": 281, "DNA_sequence": "GTACCGTAGTCATGCAGTA","direction":"reverse","function":"function3","fill":"blue", "y":100}];
console.log(gene_Datateach);
svg.selectAll("rect")
.data(gene_Datateach)
.enter()
.append("rect")
.attr("y",function (d){
if (d.direction == "forward"){
return 100;
}
else {return 200;
}
})
.attr("x",function(d){return d.start;})
.attr("width", function(d){return d.end- d.start})
.attr("height", 50)
.attr("fill",function (d){
if (d.direction == "forward"){
return "red";
}
else {return "blue";
}
})
.attr("opacity", 0)
.attr("stroke","black")
.text(function(d){return d. DNA_sequence})
.transition()
.duration (1500)
.delay (function (d, i){return i *1000;})
.attr ("opacity",1)
;
/*
var blueflag={type:"rectangle",x: "200",y:"100",width:"50",height:"150",color:"blue"}
var redflag= {type:"rectangle",x:"315",y:"100",width:"50",height:"150",color:"red"}
var whiteflag={type:"rectangle",x:"250",y:"100",width:"50",height:"150",color:"white"}
/*
svg.append("rect")
.attr("y", 100)
.attr("x", 200)
.attr("width", 50)
.attr("height",150)
.attr("fill", "blue");
svg.append("rect")
.attr("y", 100)
.attr("x",250)
.attr("width",50)
.attr("height",150)
.attr("fill","ghostwhite");
svg.append("rect")
.attr("y", 100)
.attr("x", 315)
.attr("width", 50)
.attr("height",150)
.attr("fill", "red");
*/
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment