This is not strictly a D3 question; anyway your browser supports
loading external SVG, you can use with D3. One way is to embed an img
tag in your HTML:
<body>
<img src="tux.svg" width="335" height="394" />
</body>
You could also do this in JavaScript:
var tux = new Image;
tux.onload = function() { console.log("Hooray, Tux is here!"); };
tux.src = "tux.svg";
However, I'm not sure that you get access to the SVG dom when you load
it inside an img element.
Another thing you could try would be using d3.xml, and then embedding
the document fragment in the page. I have no idea if that will work
but it seems possible.
https://github.com/mbostock/d3/wiki/Requests#d3_xml
Mike
Mike
var nodes = d3.select(importedNode).selectAll("g")
nodes.attr("fill", "#990000");
And then set the overall size of each svg like so:
importedNode.width.baseVal.value = 50;
importedNode.height.baseVal.value = 50;
This is basically what I was looking for when I found this thread ;-D the ability to load SVG documents and then manipulate them. The SVGSVGElement mentions matrix transforms which seems pretty complex - does D3 offer something similar? easier?
You are right. But I was just wondering if an object tag was more appropriate to inline svg or iframe to load an external svg to be able to manipulate it with D3. As I understand, D3 typically generate inline svg (browser support). I will test to see if I can manipulate a svg in an image tag with d3 (browser support) But I don't think it will be difficult to play in an object tag with D3. But maybe more within an iframe.
--
You received this message because you are subscribed to a topic in the Google Groups "d3-js" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/d3-js/-qYDy71c_lA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to d3-js+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
http://bl.ocks.org/bollwyvl/fe1d2806449487cdf88a
http://bl.ocks.org/bollwyvl/fe1d2806449487cdf88a#reveal-svg-fragment.js
I've tried plain-old appendChild, importNode and all kinds of other things, and it has no impact on Firefox rendering.item.idoc.select("body") .append("div").attr({width: "100%", height: "100%"}).style({position: "relative"}).node().appendChild(document.adoptNode(xml.documentElement));
http://bl.ocks.org/bollwyvl/fe1d2806449487cdf88a/9692895eef9f7ac077819441cb199187ed4025aa
function add_part () {d3.select("svg").append("object").attr("data", "/parts/IC-8pin.svg").attr("type", "image/svg+xml"); }--
You received this message because you are subscribed to the Google Groups "d3-js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to d3-js+un...@googlegroups.com.