Create a gist now

Instantly share code, notes, and snippets.

anonymous /README.md
Created Dec 9, 2015

fresh block
<!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>
<svg>
</svg>
<script>
var body = d3.select('body');
console.log(body);
var header = body.append('h1').text('hello world');
header.style('font-size', '55px')
.style('color', 'orange').
attr('id', 'main')
.attr('class', 'header');
console.log(header.attr('class'));
// selecting things based on the attrs (css) tags!
d3.selectAll('#main')
.style('color', 'blue')
.style('font-family', 'comic sans');
var svg = d3.select('svg');
for (var i = 0; i < 500; i++) {
var x = Math.random() * 200;
var y = Math.random() * 200:
var radius = Math.random() * 10 + 1;
svg.append('circle')
.attr('cx', x)
.atrr('cy', y)
.attr('r', radius);}
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment