Accessible bar chart in Flash
It’s getting even more common to deal with clients that need an accessible site (this happens in general with big corporates or government institutions). An HTML based solution is always the best choice for this, also because from the tests I did so far there are too many variables to permit to a screenreader to read and browse Flash content. The problem is when the client wants also something engaging and appealing, for this reason JavaScript can’t be compared to Flash: a solution like that would require much more time due to many compatibility issues.
Taking inspiration from the technique used by sIFR (Rich Accessible Typography for the Masses), I thought to replace a HTML chart with a Flash applet where I pass as data the code of the initial chart itself. We are defintely talking about much more complex data then simple text, and for this reason they have to be structured. XML, of course, is the best way, so I instantly decided that the initial chart should have to be in XHTML.
Not being an Accessibility expert, the first thing I did was to google for an accessible XHTML chart. I found then this example, wonderful for its semplicity but that, I have to admit, required small modifications, that I tried to fix as much as I could, to be as mush accessible that possible.
I thought it was enough to get the XHTML code with the innerHTML property of the element containing the chart and passing it straight to the SWF in its FlashVars parameter, but instead the typical browser issues came up. For instance, the innerHTML property, even if the page is in XHTML, returns always HTML code and — without closing tags like BR and IMG — it breaks unavoidably the XML formatting. Netscape based browsers embed a serializer (XMLSerializer class) that does a wonderful job, but we can’t renunce to IE compatibility, at least with Windows. The remaining solution is to convert the HTML coming from innerHTML to XHTML. To build this converter have been crucial the Regular Expressions (regexp). Being a very customized solution, so where the used tags are known, it has been enough a relatively simple regexp that so can’t be definitely considered very consistent, if we imagine, for instance, the eventual usage for new tags added later on.
This is the final result that, I want to clarify, rests an example of a possible technique and so very far from a final solution adaptable automatically to any context.
By the way I hope someone can take inspiration for this approach too and maybe investigate more on the potentialities. Here are the source files of all the experiment.