Moop
Moop

Reputation: 93

How to force Raphael JS to output as svg

I'm currently trying to generate pdf from an html page with charts generated by raphael.

It works great on every browser except internet explorer < 9 for which raphael use vml.

I'm using wkhtmltopdf to convert the page, it's using webkit to render the page so it doesn't support vml when IE is used.

Is there a way to force Raphael to render svg instead of vml in IE? I know it won't display, but what I would do is render it once in vml and a second time in svg.

I've seen that I can set the property

Raphael.type = "SVG";
Raphael.svg = true; 

but it doesn't work after the object has been instantiated.

Upvotes: 3

Views: 1440

Answers (3)

Blaise
Blaise

Reputation: 13479

I too am one of those people that want Internet Explorer to generate an SVG. It doesn't have to be displayed, just sent to the server. So I looked into this:

You can force Raphael into thinking it should generate an SVG doing so:

    var rProto, paper;

    rProto = Raphael.prototype.raphael;
    rProto.svg = true;
    rProto.vml = false;
    rProto.type = 'SVG';

    var paper = Raphael(...);

However, Raphael will now throws tons of errors, because Internet Explorer will follow the codepath of modern browsers, which will obviously not work. I looked at those errors and they don't seem trivial to fix or work around.

Upvotes: 2

jjmontes
jjmontes

Reputation: 26875

According to this thread (a bit old though) there is no way to make IE accept SVG elements:

http://groups.google.com/group/raphaeljs/browse_thread/thread/5a05193c0334bda7/25776b86e78d3c2f?lnk=gst&q=force+svg#25776b86e78d3c2f

However, I don't understand what you mean with "it's using webkit so it doesn't support VML when IE is used". As far as I know, WebKit is a different renderer and it is in no way related to IE. Perhaps if you develop a bit further in your issue, we can help finding a solution.

Upvotes: 0

Andrew
Andrew

Reputation: 13853

A lot of the commands reference R.vml try setting that as well,

Raphael.vml = false;

Upvotes: 0

Related Questions