Skip to content

Instantly share code, notes, and snippets.

@d3byex
Created November 23, 2015 07:24
Show Gist options
  • Save d3byex/c4750ed3492ca13a32aa to your computer and use it in GitHub Desktop.
Save d3byex/c4750ed3492ca13a32aa to your computer and use it in GitHub Desktop.
D3byEX 9.1: Line Generator
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="D3byEX 9.1" />
<meta charset="utf-8">
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var svg = d3.select('body')
.append('svg')
.attr({
width: 500,
height: 250
});
var data = [
{ X: 10, Y: 10 },
{ X: 60, Y: 60 },
{ X: 80, Y: 20 }
];
var generator = d3.svg.line()
.x(function (d) { return d.X; })
.y(function (d) { return d.Y; });
svg.append('path')
.datum(data)
.attr({
d: generator,
stroke: 'steelblue'
});
svg.append('path')
.datum(data)
.attr({
transform: 'translate(100,0)',
d: generator,
fill: 'none',
stroke: 'steelblue'
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment