<p>I need to display some interactive (attaching with DOM listeners etc. and event handling) vector graphics in web site I am working on. There is a W3C recommendation for SVG though this format is still not recognized by Internet Explorer support of which is a must (for a public website). IE handles VML though and there are even javascript libraries that do some canvas-like drawing depending on a browser (SVG vs. VML) - <a href="http://excanvas.sourceforge.net/" rel="noreferrer" title="excanvas">excanvas</a>, <a href="http://dojotoolkit.org/book/dojo-book-0-9/part-3-programmatic-dijit-and-dojo/drawing-gfx" rel="noreferrer">GFX of Dojo Toolkit</a> and more. That would be nice and acceptable though none of them can display an SVG image from the given markup.</p>

<p>So the question actually consists of several parts:</p>

<ol>
<li>Are there any cross-browser Javascript libraries that display vector graphics from given markup (not obligatory SVG) and offer availability to attach to DOM events?</li>
<li>If there are not, which of the most pupular browser-embedded technologies would be most suitable for doing such a task? I can choose from Flex/Flash, Java applet. Silverlight is not an option because of Windows lock-in.</li>
</ol>

<p>[<strong>EDIT</strong>] Thank you all for your comments/suggestions. Below are just some my random notes/conclusions on this matter:</p>

<ul>
<li>The level of interactivity I need is ability to detect DOM events on the vector image being displayed - mouseover, mouseout, click etc. - and ability to react on them like changing background color, displaying dialog etc.</li>
<li>The idea of sticking with SVG format is quite well as it is native on many browsers except the most popular one - IE. After some experimenting with displaying dynamic SVG I realized that IE version 7 the most problematic. There's too much hassle because of browser incompatibilities.</li>
<li>Cake seems a great Javascript framework, though I could not get the examples working on IE7.</li>
<li>Java Applets - I liked that idea the most as I though I could use the Apache Batik library, a quality SVG renderer. However, Batik is very big library and I cannot afford deploying an applet that weights few megabytes.</li>
<li>I decided to stick with the Flex option. I found a nice vector graphics library <a href="http://www.degrafa.com/" rel="noreferrer">Degrafa</a>. It uses its own markup format however it recognizes SVG path notation, so in my case it is going to be quite easy to transform my SVGs using XSLT or just parsing them.</li>
</ul>

<p>[<strong>EDIT 2</strong>] Some more comments appeared. I'd like to clarify that by "Windows lock-in" I mean the situation that Silverlight would normally run on Windows, more specifically, IE. I doubt it is an accepted solution (like Flash or Java Applet, for instance) on other systems. Yes, I have no doubt that one <em>is able to</em> launch Silverlight app on any system though I fear it would be too much effort for an average user.</p>

<p>@Akira: Have you had any problems with those "SVG renderers" on IE7? I get thrown Javascript errors all the time.</p>

[{'answer_id': 9624, 'author': 'Greg Hewgill', 'author_id': 893, 'author_profile': 'https://Stackoverflow.com/users/893', 'pm_score': 1, 'selected': False, 'text': '<p>Have a look at the new <a href="http://en.wikipedia.org/wiki/Canvas_(HTML_element)" rel="nofollow noreferrer">Canvas</a> element which has been implemented in many browsers. I heard also that there is an ActiveX control for IE that implements the Canvas element too.</p>\n\n<p>Update: Wait, you already said that. I should read the whole question next time! :)</p>\n'}, {'answer_id': 9627, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>Go for SVG - and just tell the users to get the ADOBE SVG plug in for IE.</p>\n\n<p>See this excellent site - which is a UK Government Site (public service)</p>\n\n<p><a href="http://www.elgin.gov.uk" rel="nofollow noreferrer">ELGIN</a></p>\n'}, {'answer_id': 9634, 'author': 'Keith', 'author_id': 905, 'author_profile': 'https://Stackoverflow.com/users/905', 'pm_score': 0, 'selected': False, 'text': "<p>IE supports VML, but nothing else does and it's ugly.  Microsoft claimed that they'd dropped it (with new XAML and all) but it's still part of their Office XML format (it's how Excel .xlsx supports comments, weirdly enough).</p>\n\n<p>FX and loads more support the new Canvas element.  Many support SVG, but given the work MS are doing on Silverlight I can't see IE supporting SVG any time soon.</p>\n\n<p>Microsoft are supposed to be providing Silverlight plug ins for no MS operating systems.</p>\n\n<p>I've been using Flex - it's pretty good despite using Eclipse. You don't need to buy the hugely expensive Adobe server components to use Flex - it can consume SOAP services.</p>\n\n<p>The dev tools for Flex are quite affordable, and nearly everyone has Flash.</p>\n"}, {'answer_id': 9637, 'author': 'Christian Lescuyer', 'author_id': 341, 'author_profile': 'https://Stackoverflow.com/users/341', 'pm_score': 0, 'selected': False, 'text': '<p>I don\'t think SVG is a good choice for the future. From <a href="http://en.wikipedia.org/wiki/Scalable_Vector_Graphics" rel="nofollow noreferrer">Wikipedia</a>:</p>\n\n<ul>\n<li>"The most common IE plugin was produced by Adobe. Adobe, however, are planning to withdraw this product at the beginning of 2009"</li>\n<li>"... Internet Explorer which will also not support SVG in the upcoming version IE8"</li>\n<li>"...all have incomplete support for the SVG 1.1..."</li>\n<li>"The Corel SVG Viewer plugin was once offered from Corel. Its development has stopped."</li>\n</ul>\n'}, {'answer_id': 9654, 'author': 'olliej', 'author_id': 784, 'author_profile': 'https://Stackoverflow.com/users/784', 'pm_score': 3, 'selected': False, 'text': '<p>Safari, Opera and Firefox all support SVG natively (eg. without plugins) to varying degrees of completeness and correctness, including the ability to script the svg from javascript.</p>\n\n<p>There\'s also the canvas element which is now being standardised in html5, and is already supported in the above browsers as well (with various quirks in certain edge cases due to relatively recent changes in the html5 draft).</p>\n\n<p>Unfortunately any standards based approach is kind of destroyed by IE\'s willful disregard of what is happening outside its own ecosystem, however there are a number of libraries that try to convert canvas/svg into VML (IE\'s proprietary vector language) such as <a href="http://sourceforge.net/projects/iecanvas" rel="noreferrer">iecanvas</a>.</p>\n\n<p>[Edit: whoops, i forgot my favourite js library -- <a href="http://glimr.rubyforge.org/cake/canvas.html#SVGParserTest" rel="noreferrer">Cake</a>! which can parse and display svg in canvas, and believe supports IE as well]</p>\n\n<p>[Yet another edit: Cake actually has a <a href="http://glimr.rubyforge.org/cake/canvasmage.html" rel="noreferrer">demo</a> doing what i think you want to do]</p>\n'}, {'answer_id': 9668, 'author': 'graham.reeds', 'author_id': 342, 'author_profile': 'https://Stackoverflow.com/users/342', 'pm_score': 3, 'selected': False, 'text': '<p>Take a look at the <a href="http://raphaeljs.com/" rel="nofollow noreferrer">Raphael Javascript library</a>. It\'s early days but it looks very promising.</p>\n\n<p>I remember the IE roadmap that had SVG support listed in IE7.2. </p>\n\n<p>Depends on how interactive you want it?</p>\n'}, {'answer_id': 9723, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': "<p>Of all the possibilities you list, the only one that's not a horrible abuse of an existing technology (Javascript), barely supported (SVG, Canvas element) or a lot of work (Java) is Flash.  It was designed as a vector graphics package and is compatible with more browsers than SVG and the canvas tag.</p>\n\n<p>The only reason I wouldn't choose Flash over all other options is if you're aiming at mobile browsers or don't have the budget for the Flash package.</p>\n"}, {'answer_id': 13032, 'author': 'Jon Galloway', 'author_id': 5, 'author_profile': 'https://Stackoverflow.com/users/5', 'pm_score': 2, 'selected': False, 'text': '<p>Can you clarify what you mean by the "Windows lock-in" thing with Silverlight? It runs on Windows and MacIntel, and the vector portions run just fine on Linux with the Moonlight plugin.</p>\n\n<p>Were you thrown off by the lack of Amiga support?</p>\n'}, {'answer_id': 78854, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>Walter Zorn has a <a href="http://walterzorn.com/jsgraphics/jsgraphics_e.htm" rel="nofollow noreferrer">JavaScript library</a> for arbitrary vector graphics. It looks decent.</p>\n'}]
['https://Stackoverflow.com/questions/9615', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/837/']