Created
June 19, 2018 18:08
-
-
Save panathea/1befd0f7ea11532af4510f3a8f819012 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/gist
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> | |
<meta charset="utf-8"> | |
<head> | |
<title>Line (using curveCardinal)</title> | |
</head> | |
<style> | |
path { | |
fill: none; | |
stroke: #999; | |
} | |
circle { | |
fill: none; | |
stroke: #aaa; | |
} | |
</style> | |
<body> | |
<svg width="700" height="300"> | |
<path></path> | |
</svg> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script> | |
<script> | |
var lineGenerator = d3.line() | |
.curve(d3.curveCardinalClosed); | |
var points = [ | |
[50, 40], | |
[220, 80], | |
[550, 30], | |
[550, 80], | |
[400, 170], | |
[220, 200], | |
[50, 140], | |
]; | |
var pathData = lineGenerator(points); | |
d3.select('path') | |
.attr('d', pathData); | |
// Also draw points for reference | |
d3.select('svg') | |
.selectAll('circle') | |
.data(points) | |
.enter() | |
.append('circle') | |
.attr('cx', function(d) { | |
return d[0]; | |
}) | |
.attr('cy', function(d) { | |
return d[1]; | |
}) | |
.attr('r', 3); | |
</script> | |
<script id="jsbin-javascript"> | |
sadfsdfsafsdsdsadf | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">sadfsdfsafsdsdsadf</script></body> | |
</html> |
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
sadfsdfsafsdsdsadf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment