Created
July 31, 2012 14:00
-
-
Save nkhine/3217249 to your computer and use it in GitHub Desktop.
cube in D3
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
/** | |
* cubeD3 Create a rotating cube with D3.js: | |
* | |
* @param id div id tag starting with # | |
* @param width width of the grid in pixels | |
* @param height height of the grid in pixels | |
* @param square | |
*/ | |
function cubeD3(id, width, height) | |
{ | |
var svg = d3.select(id); | |
// Add SVG canvas | |
svgcanvas = svg.append("svg:svg") | |
.attr("width", 325) | |
.attr("height", 250); | |
// Background dark gray rectangle | |
svgcanvas.append("svg:rect") | |
.attr("x",0) | |
.attr("y",0) | |
.attr("width",325) | |
.attr("height",250) | |
.style("fill", "rgb(125,125,125)"); | |
} |
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> | |
<title>Cube using d3.js</title> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.v2.js"></script> | |
</head> | |
<body> | |
<div id="cube"></div> | |
<script type="text/javascript" src="cube.js"></script> | |
<script type="text/javascript"> | |
cubeD3('#chart', 500, 500); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a square.