Skip to content

Instantly share code, notes, and snippets.

@stephenmaturin
Created July 31, 2012 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephenmaturin/3217448 to your computer and use it in GitHub Desktop.
Save stephenmaturin/3217448 to your computer and use it in GitHub Desktop.
Cannot select SVG foreign object in d3
function run() {
svg = d3.select("#example_svg");
console.log(svg.selectAll("circle"));
console.log(svg.selectAll("foreignObject"));
}
<html>
<head>
<title>Cannot Select SVG Foreign Object</title>
<script src="http://d3js.org/d3.v2.js"></script>
<script src = "fo_select.js"></script>
</head>
<body>
<svg id="example_svg" width="600" height="600">
<g>
<circle r="40" cx = "80" cy="80"></circle>
<foreignObject width = "100" height = "100" x = "200" y="200">
<body>Hello, world</body>
</foreignObject>
</g>
</svg>
<script>run()</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment