Created
October 10, 2011 16:31
-
-
Save jeffpflueger/1275742 to your computer and use it in GitHub Desktop.
Experiment 1 with d3 and svgweb
This file contains hidden or 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> | |
<!-- SVG web to turn svg into flash for IE | |
This might not be working on bl.ocks.org for the following reasons: | |
1) MIME types not added to the bl.ocks.org webserver: | |
AddType text/x-component htc | |
AddType application/x-shockwave-flash swf | |
AddType image/svg+xml svg | |
2) data-path must be relative path, not URL (http://jeffpflueger.com/svgweb/src) | |
--> | |
<script src="http://jeffpflueger.com/svgweb/src/svg.js" data-path="http://jeffpflueger.com/svgweb/src"></script> | |
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.27.2"></script> | |
<style type="text/css"> | |
circle { | |
fill: #ccc; | |
stroke: #777; | |
stroke-width: 5px; | |
} | |
</style> | |
</head> | |
<body> | |
<!-- Here's what d3 generates from this: | |
<svg height="500" width="960"><circle r="50" cy="200" cx="200"></circle></svg> | |
If you'd like to test if svgweb is working, just copy and paste the above in | |
between the script tags below.... | |
and once you do that, this is what svgweb creates: | |
<svg id="__svg__random___0" width="960" height="500" xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><circle cx="200" cy="200" r="50"></circle></svg> | |
but unfortunately, we run into errors from svgweb if we try to have svgweb read the svg created by d3.js: | |
--> | |
<script id='tag' type="image/svg+xml"> | |
</script> | |
<script type="text/javascript"> | |
var w = 960, | |
h = 500 | |
var chart = d3.select("script#tag").append("svg:svg") | |
.attr("width", w) | |
.attr("height", h); | |
chart.append("svg:circle") | |
.attr("cx", 200) | |
.attr("cy", 200) | |
.attr("r", 50); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment