Created
October 3, 2011 03:17
-
-
Save biovisualize/1258361 to your computer and use it in GitHub Desktop.
Append node already in the DOM
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script> | |
<title></title> | |
</head> | |
<style type="text/css"> | |
</style> | |
<body> | |
<div id="viz"> | |
<script type="text/javascript"> | |
var toAppend = d3.select("#viz") | |
.append("svg:circle") | |
.attr("cx", 50) | |
.attr("cy", 50) | |
.attr("r", 25) | |
.attr("fill", "dodgerblue"); | |
var importedNode = document.importNode(toAppend.node(), true); | |
var rootSVG = d3.select("#viz") | |
.append("svg:svg") | |
.attr("width", 200) | |
.attr("height", 100) | |
.style("background-color", "skyblue"); | |
rootSVG.append("svg:rect") | |
.attr("x", 50) | |
.attr("y", 10) | |
.attr("width", 100) | |
.attr("height", 75) | |
.attr("fill", "blue"); | |
rootSVG.node().appendChild(importedNode); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment