Skip to content

Instantly share code, notes, and snippets.

@biovisualize
Created June 13, 2016 20:58
Show Gist options
  • Save biovisualize/d45b71106b11e96610857279c04debad to your computer and use it in GitHub Desktop.
Save biovisualize/d45b71106b11e96610857279c04debad to your computer and use it in GitHub Desktop.
fresh block
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v3.js"></script>
<style>
.bar {
background-color: orange;
position: relative;
float: left;
margin-right: 10px;
}
</style>
</head>
<body>
<div class="container"></div>
<script>
var containerSelection = d3.select('.container')
.style({
width: '500px',
height: '300px',
'background-color': 'aliceblue'
});
containerSelection.selectAll('div.bar')
.data([1, 2, 3, 4])
.enter().append('div')
.attr({
class: 'bar'
})
.style({
height: function(d){ return d*50; },
top: function(d){ return 300 - d*50; },
width: '20px'
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment