开发者

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.


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.


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

Raphael.vml = false;


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜