Skip to content

Instantly share code, notes, and snippets.

@eoiny
Created March 22, 2017 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eoiny/4eb05632f32c39d992e3850ed97bb86a to your computer and use it in GitHub Desktop.
Save eoiny/4eb05632f32c39d992e3850ed97bb86a to your computer and use it in GitHub Desktop.
fresh block
license: mit
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
</style>
</head>
<body>
<script>
// Feel free to change or delete any of the code you see in this editor!
var data = [1, 2, 3, 4, 5];
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500);
var margin = {top:20, right:30, bottom: 30, left: 30};
var width = 960 - margin.left - margin.right;
var height = 500 - margin.top - margin.bottom;
var g = svg.append('g')
.attr('transform', 'translate('+ margin.left +', ' + margin.top + ')');
var bar = g.selectAll('.bar')
.data(data)
.enter()
.append('rect')
.attr('class', 'bar')
.attr('width', 60)
.attr('x', function(d,i){
return i * 70;
})
.attr('height', function(d,i){
return d * 10;
})
.style('fill', 'steelblue');
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment