Last active
December 30, 2015 04:29
-
-
Save ariutta/7776406 to your computer and use it in GitHub Desktop.
d3.xml test case
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> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | |
width: 960px; | |
height: 500px; | |
position: relative; | |
} | |
</style> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script> | |
var svg = d3.select("body").append("svg") | |
.attr("width", 1000) | |
.attr("height", 1000); | |
var defs = svg.append("defs"); | |
var symbol = defs.append("symbol") | |
.attr("id", "oval-symbol"); | |
d3.xml("oval.svg", "image/svg+xml", function(svgXml) { | |
var shape = d3.select(svgXml.documentElement) | |
var width = shape.attr('width'); | |
var height = shape.attr('height'); | |
symbol.attr('viewBox', '0 0 ' + width + ' ' + height); | |
var shapeChildren = shape[0][0].children; | |
var i = -1; | |
do { | |
i += 1; | |
symbol[0][0].appendChild(shapeChildren[i]); | |
} while (i < shapeChildren.length - 1); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment