views:

276

answers:

1

I have an SVG file that I would like to display via Raphael (each svg file is a node in a tree I'm trying to draw, the actual connections of the tree will be made by raphael). I tried something like:

var vector_image = paper.image("test.svg", 50,50,50,50);

but no dice, seems only "real" image files like png or jpeg are accepted? I find this very strange as Raphael itself uses Scalable Vector Graphics.

Is there anyway (short of parsing the SVG files into javascript snippets and pasting them into the html document) to display existing SVG files using Raphael (or any other vector based javascript graphical engine?)

If parsing it will have to be, is there any easy way to do this, short of just manually scraping the files? I'm running this code on a Ruby on Rails server, so I'd like to avoid solutions outside this framework, if possible (I've heard of one PHP solution through this site...I'd rather code by hand than add another language onto this project).

-Jenny

+1  A: 

It's currently not possible to display existing SVG with Raphael, and there are apparently no plans for the implementation of SVG editing (see this forum post). As for alternative JavaScript libraries, SVGWeb allows you to embed SVG in your page, and interact with it via JavaScript. It renders SVG in non-SVG-enabled browsers using flash.

Daniel
thanks for the help! I'll look into SVG Web, but at this point I'm so immersed in parsing the simple files I need into Raphael it's probably simplest to just keep going...
Jenny