Skip to content

Instantly share code, notes, and snippets.

@mango314
Created March 2, 2013 00:21
Show Gist options
  • Save mango314/5068996 to your computer and use it in GitHub Desktop.
Save mango314/5068996 to your computer and use it in GitHub Desktop.
a lissajous curve
<html>
<head>
</head>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script type="text/javascript">
//The data for our line
var lineData = Array();
for(var i=0; i < 1000; i++){
lineData.push({"x": 100*Math.cos(3*2*3.14159*i/180)+125, "y":100*Math.sin(5*2*3.14159*i/180) +125 } );
}
//This is the accessor function we talked about above
var lineFunction = d3.svg.line()
.x(function(d) { return d.x; })
.y(function(d) { return d.y; })
.interpolate("linear");
//The SVG Container
var svgContainer = d3.select("body").append("svg")
.attr("width", 300)
.attr("height", 300);
//The line SVG Path we draw8
var lineGraph = svgContainer.append("path")
.attr("d", lineFunction(lineData))
.attr("stroke", "blue")
.attr("stroke-width", 2)
.attr("fill", "none");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment