Built with blockbuilder.org
xxxxxxxxxx
<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_data = [{"name":"1", "start": 20,"end":100, "direction": "F","y":100, "function": "function_1","fill":"blue"},
{"name":"2", "start": 120,"end":200, "direction": "F","y":100, "function": "function_2","fill":"green"},
{"name":"3", "start": 220,"end":300, "direction": "R","y":160, "function": "function_3","fill":"red"},
{"name":"4", "start": 320,"end":400, "direction": "F","y":100, "function": "function_4","fill":"purple"}]
console.log(gene_data);
svg.selectAll("rect") //selects anything in the svg data file
.data(gene_data) //data join... what connects the data to making the pic
.enter()
.append("rect")
.attr("y",function(d) {return d.y;})
.attr("x", function(d) {return d.start;})
.attr("d", function(d) {return d.direction;})
.attr("f", function(d) {return d.function;})
.attr("width", function(d) {return d.end-d.start;})
.attr("height", 50)
.attr("fill", function (d) {return d.fill})
</script>
</body>
https://d3js.org/d3.v4.min.js