Skip to content

Instantly share code, notes, and snippets.

@e9t
Last active December 11, 2015 21:39
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 e9t/4664433 to your computer and use it in GitHub Desktop.
Save e9t/4664433 to your computer and use it in GitHub Desktop.
SNU DMLab logo
var width = 170;
var height = 170;
var root = d3.select('#chart').append('svg')
.attr('width', width)
.attr('height', height)
var rects = [
{ x: 10, y: 40, w: 50, h: 50, fill: '#bd7' },
{ x: 10, y: 90, w: 50, h: 50, fill: '#bd7' },
{ x: 60, y: 40, w: 50, h: 50, fill: '#8B3' },
{ x: 60, y: 90, w: 50, h: 50, fill: '#8B3' },
{ x: 110, y: 40, w: 50, h: 50, fill: '#184' },
{ x: 110, y: 90, w: 50, h: 50, fill: '#184' },
];
root.selectAll('rect')
.data(rects).enter()
.append('rect')
.attr('x', function(d) { return d.x; })
.attr('y', function(d) { return d.y; })
.attr('width', function(d) { return d.w; })
.attr('height', function(d) { return d.h; })
.attr('fill', function(d) { return d.fill })
.attr('stroke-width', 10)
.attr('stroke', 'whitesmoke');
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<body>
<div id="chart"></div>
<script type="text/javascript" src="dmlab.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment