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>
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500)
var gene = [{"fill": "blue","x": 200,"y": 200},
{"fill": "green","x": 200,"y": 250
},
{"fill": "red","x": 200,"y": 150
}];
console.log(gene);
svg.selectAll("rect")// creates a selection
.data(gene)// reads flag var
.enter() //does something about the above function.
.append("rect")
.attr("width", 200)// or .attr("width",function (d) {return d.width})
.attr("height", 50)
.attr("fill", function (d) {return d.fill;})
.attr("y", function(d) {return d.y;})
.attr("x", function(d) {return d.x;})
// stroke can be done with this one as well
// d3 data binding
/*svg.append("rect")
.attr("y", 10)
.attr("x", 0)
.attr("width", 200)
.attr("height", 400)
.attr("fill", "#0055A4");
svg.append("rect")
.attr("y", 10)
.attr("x", 200)
.attr("width", 200)
.attr("height", 400)
.attr("fill", "#FFFFFF");
svg.append("rect")
.attr("y", 10)
.attr("x", 400)
.attr("width", 200)
.attr("height", 400)
.attr("fill", "#EF4135");
*/
</script>
</body>
https://d3js.org/d3.v4.min.js