Tuesday 1 May 2007

Pacman meets XML/SWF Charts

I came across this image on an backwater Slashdot thread and it gave me a chuckle. (Note: I can't find who owns the copyright on this, it's widely published around the net though.)
...meanwhile we've been experimenting extensively with this XML/SWF Charts Library. It's a pretty neat simple to use Library with a huge range of very impressive charts. It's not perfect but it nearly is and it's extremely competitively priced. It consists of an embeddable SWF object that you pass a XML feed to. The rendering is then done on the client side. The appeal of this is that the load on the server can be reduced with out sacrificing the visual effect. I've used it to produce a GlowDay version of the Pacman Pie Chart. You might want to refresh to see the animation it all it's naff.






My main complaint is it mixes presentation and data together in one XML feed.
Aside from the fact that this is a violation of separation of concerns process, it has a major practical consequence, every time you update the data you have to republish the presentation layer too. This means more bandwidth consumed. In the example above the data feed is about 3K of which 309 bytes is the data portion. This means 90% of the bytes downloaded might never change. What's especially annoying about this is that the chart library caches the data file so you have to resort to appending a unique number to the data file URL to stop this happening, more bandwidth consumed unnecessarily, and if you not careful with your server side implementation more server horsepower consumed re-generating your data file.

My other complaint is that there doesn't appear to be a schema available for the XML feeds. This is poor, in my book XML with out a DTD or an XSD is not XML it's a proprietary format. While the documentation for the libary is excellent there are ambiguities in places and an XSD with eliminate them. I'm using JAXB at the back end to generate the chart data for publishing so a schema was really a necessity.

The website had lot's of sample documents so I thought, Trang to the rescue! Trang is a sort of XML Swiss Army Knife written by James Clark the XML Guru. (Incidentally this is my preferred Swiss army knife at the moment ) . Trang allows you convert to and from these XML languages:
  • RELAX NG (XML syntax)
  • RELAX NG compact syntax
  • XML 1.0 DTDs
  • W3C XML Schema
More importantly for my purpose it allows you to infer a schema from a collection of samples. The command line documentation is a little vague on how to do this but eventually I got it to work. Hey Presto! one XSD here for all to use. It does a pretty good job, It's not perfect but it seems close enough so far.

Despite these gripes we're going to be using XML/SWF charts for a while anyway.

Daniel

3 comments:

The Lal said...

Hmmm.. something 2 do with charts ...

wow - I'm close right....

so that means u're business plan is xyz

getting warmer - huh!

Anonymous said...

A new version 5 of XML/SWF Charts is now available:
http://www.maani.us/xml_charts

It includes scrolling, streaming, full screen mode, filter effects, and much more!

Addicting Games said...

Yaaaiy! Pac-Man chart!! Funny ^^
Anyway if you are a Pac-man lovers, take a visit to my Download Games website.