-
-
Save nick3499/9e67a54d26eabb81f77071efae3dc751 to your computer and use it in GitHub Desktop.
D3byEX 9.1: Line Generator (Adapted to D3.js v4)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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