Created
November 8, 2017 11:16
-
-
Save valex/f2e6c289efe4f106a86ba8591ac46430 to your computer and use it in GitHub Desktop.
Creating a sequence of lines
This file contains hidden or 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> | |
<head> | |
<meta charset="utf-8"> | |
</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