Built with blockbuilder.org
xxxxxxxxxx
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style type="text/css" >
div.bar{
display: inline-block;
width: 40px;
height: 90px;
background-color: teal;
margin-right:2px;
}
div.bar2{
display: inline-block;
width: 40px;
height: 90px;
background-color: pink;
margin-right:2px;
}
div.bar3{
display: inline-block;
width: 40px;
height: 90px;
background-color: blue;
margin-right:2px;
}
</style>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg { width: 100%; height: 100%; }
</style>
</head>
<body>
<script type="text/javascript">
var dataset = [5,10,15,20,25];
d3.select("body").selectAll("div")
.data(dataset)
.enter()
.append("div")
.attr("class","bar")
.style("height",function(d){
return d*5+"px";
});
var dataset2 = [7,68,15,32,77,25,19,33,45,68];
d3.select("body").selectAll("div.bar2")
.data(dataset2)
.enter()
.append("div")
.attr("class","bar2")
.style("height",function(d){
var barHeight=d*5;
return barHeight+"px";
});
var dataset3 = [];
for(var i=0; i<15; i++){
var newNumber = Math.floor(Math.random()*100);
dataset3.push(newNumber);
}
d3.select("body").selectAll("div.bar3")
.data(dataset3)
.enter()
.append("div")
.attr("class","bar3")
.style("height",function(d){
var barHeight=d*5;
return barHeight+"px";
})
.style("background-color",function(d){
if(d < 60){
return"red";
} else {
return"black";
}
});
</script>
</body>
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js