Skip to content

Instantly share code, notes, and snippets.

@nick3499
Forked from d3byex/index.html
Last active March 8, 2017 23:06
Show Gist options
  • Save nick3499/9e67a54d26eabb81f77071efae3dc751 to your computer and use it in GitHub Desktop.
Save nick3499/9e67a54d26eabb81f77071efae3dc751 to your computer and use it in GitHub Desktop.
D3byEX 9.1: Line Generator (Adapted to D3.js v4)
<!DOCTYPE html>
<html>
<meta charset=utf-8>
<head>
<meta name="description" content="D3.js v4, line sequence, SVG
container" />
</head>
<body>
<script src="http://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/d3-selection-multi.v1.min.js"></script>
<script>
var svg = d3.select('body')
.append('svg')
.attrs({ width: 500, height: 250 });
var data = [ { X: 10, Y: 10 }, { X: 60, Y: 60 }, { X: 80, Y: 20 } ];
var generator = d3.line()
.x(function (d) { return d.X; })
.y(function (d) { return d.Y; });
svg.append('path')
.datum(data)
.attrs({ d: generator, stroke: 'steelblue' });
svg.append('path')
.datum(data)
.attrs({ 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