Skip to content

Instantly share code, notes, and snippets.

@emmanuelflores
Last active November 18, 2015 07:51
Show Gist options
  • Save emmanuelflores/eb0b4786b47472b8b3e4 to your computer and use it in GitHub Desktop.
Save emmanuelflores/eb0b4786b47472b8b3e4 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Hello D3</title>
<script type="text/javascript" src="d3/d3.min.js"></script>
<style type="text/css">
div.bar {
display: inline-block;
width: 20px;
height: 75px;
background-color: teal;
}
</style>
</head>
<body>
<script type="text/javascript">
//var dataset = [10,20,30,40,50,60];
var dataset = [];
for(var i=0;i<30;i++){
var _number = Math.random()*30;
dataset.push(_number);
}
d3.select("body").selectAll("div")
.data(dataset)
.enter()
.append("div")
.attr("class","bar")
.style("height", function(d){
var barHeight = d*5;
return barHeight+"px";
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment