Built with blockbuilder.org
forked from Esdras08's block: Barchart (nutriments)
forked from Esdras08's block: Barchart (nutriments)
forked from Esdras08's block: Barchart (nutriments)
forked from Esdras08's block: Barchart (nutriments)
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; }
rect {
fill: none;
stroke: blue;
stroke-width: 2;
}
</style>
<svg width="50" height="50">
<circle cx="25" cy="25" r="22" fill="blue" stroke="red" stroke-width="2"/>
</svg>
</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)
d3.select("body").style("background-color", "gold")
d3.selectAll("p").style("color", function() {
return "hsl(" + Math.random() * 360 + ",100%,50%)";
});
var dataset; //Global variable
d3.tsv("nutriments.tsv", function(data)
{
console.log(data);
var y = d3.scaleLinear()
.domain([0, 67])
.range([0, 100]);
data.forEach(function(d, i) {
console.log(d);
svg.append("rect")
.attr("width", 7.5)
.attr("height", 10 * y(d.AvN))
.attr("x", i * 11)
.attr("y", 200 -10 * y(d.AvN));
});
});
</script>
</body>
https://d3js.org/d3.v4.min.js