Wednesday, October 7, 2009

Fix Dojo Charts issue on IE8

If you run your existing dojo application (built with earlier version) on IE8 then you may get error "dojo.js was not found".
To work with Dojo on IE8 you need to get the latest version of dojo (1.3) from http://dojotoolkit.org/downloads.
But if you are using dojo charts in your application then even on 1.3 version you may not be able to see the charts working properly.
To understand the reason of this issue first we need to know how charts gets rendered on browser. Basically for rendering graphics on any browser there are some standards like SVG, VML, Silverlight and Canvas etc.
For example Firefox supports SVG as renderer and IE(till version 7) uses its own standard which is VML. Dojo charts are smart enough to automatically detects the browser and selects renderer based on the browser type.
Now the issue is: In IE8 Microsoft has stopped supporting VML because as per them this is not standards-compliant. (https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=333905) and it supports Silverlight as renderer. This is why dojo charts are not working on IE8 because it was looking for VML renderer on IE8 which is no longer supported.
Solution: The dojo graphic library (gfx library) is customizable and we can specify the renderer in it. There is a special parameter in djConfig: gfxRenderer. It should be a string, which lists renderer names separated by commas in the order they should be tried by the gfx prologue. The current default is: svg,vml,silverlight,canvas". It means that on all major browsers (except IE and Safari on iPhone/iPad) SVG will be selected, VML will be used on IE, and Canvas will be used on iPhone/iPod.
http://www.nabble.com/Silverlight-testers-needed-td19343755.html#a19343755
Now for IE8 we need to change this sequence a bit and set it to gfxRenderer: 'svg,silverlight,vml,canvas'. Now for IE(till version 7) if it finds silverlight then it selects silverlight as chart renderer and if not then vml. but incase of IE8, silverlight must be on machine.
Silverlight is already being shipped with IE8.
http://www.silverlight4dummies.com/silverlight4dummies/blog/post/2009/04/Internet-Explorer-8-includes-Silverlight.aspx

so we need to specify gfxRenderer list on our pages to run dojo charts on IE8.





* dojo.js must be version 1.3 or later

please suggest if someone has any better solution.

No comments: