Skip to content

Instantly share code, notes, and snippets.

@Sokrates86
Created January 27, 2016 11:55
Show Gist options
  • Save Sokrates86/6f5fc68b63510e346913 to your computer and use it in GitHub Desktop.
Save Sokrates86/6f5fc68b63510e346913 to your computer and use it in GitHub Desktop.
Yliopiston työntekijät
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<style>
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; }
svg { width:100%; height: 100% }
</style>
</head>
<body>
<script>
var margin = {top: 30, right: 20, bottom: 30, left: 30},
w = 1200 - margin.left - margin.right
h = 1200 - margin.top - margin.bottom;
var svg = d3.select("body")
.append("svg")
.attr("width", w + margin.left + margin.right)
.attr("height", h + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
var rW = 3;
var rH = 3;
var padding = 2;
for (i = 0; i<8162; i++) {
// Feel free to change or delete any of the code you see!
svg.append("rect")
.attr("x", function() { return i%80 * rW * padding; })
.attr("y", function() { return Math.floor(i/80)*rW*padding; })
.attr("height", rW)
.attr("width", rH)
.attr("fill", function() { if (i < 981) { return "black"; }
else { return "#178FEB"}} );
}
console.log("you are now rocking with d3", d3);
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment