A modification of the dashingD3js path tutorial. You might find a lissajous curve on an oscilloscope.
Created
March 2, 2013 00:21
-
-
Save mango314/5068996 to your computer and use it in GitHub Desktop.
a lissajous curve
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
<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