Skip to content

Instantly share code, notes, and snippets.

@d3byex
Created November 23, 2015 07:25
Show Gist options
  • Save d3byex/7d49dc7635b7a74df5db to your computer and use it in GitHub Desktop.
Save d3byex/7d49dc7635b7a74df5db to your computer and use it in GitHub Desktop.
D3byEX 9.2: Area Generator
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="D3byEX 9.2" />
<meta charset="utf-8">
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
svg = d3.select('body')
.append('svg')
.attr('width', 500)
.attr('height', 250);
var data = d3.range(100)
.map(function (i) {
return Math.random() * 30;
})
.map(function (d, i) {
return { X: i * 10, Y: d }
});
var generator = d3.svg.area()
.y0(100)
.x(function (d) { return d.X; })
.y1(function (d) { return d.Y; });
svg.append('path')
.datum(data)
.attr({
d: generator,
fill: 'yellow',
stroke: 'black'
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment