Skip to content

Instantly share code, notes, and snippets.

@erizhang
Created August 4, 2014 06:13
Show Gist options
  • Save erizhang/d15f205d757265c9513e to your computer and use it in GitHub Desktop.
Save erizhang/d15f205d757265c9513e to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<style>
path {stroke: white; stroke-width: 2; fill:black;}
body, svg {background-color: black;}
</style>
</head>
<body>
<script>
var svg = d3.select('body').append('svg').attr('width', 960).attr('height', 800);
var data = d3.range(50, 650, 10).map(function(y_offset){
return d3.range(100, 700, 10).map(function(d){
var y = d;
if (y < 300 || y > 500) y = 50; else y = 500;
return [d, y_offset - Math.random() * Math.random() * y / 10];
});
});
var line = d3.svg.line()
.x(function(d) {return d[0];})
.y(function(d) {return d[1];})
.interpolate('basis');
svg.selectAll('path').data(data).enter()
.append('path').attr('d', line);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment