This post contains attachments v20020313183135.zip 
Summary
Using XSLT to produce a simple pie chart from XML data.
To try this code in Xselerator, please install the 30 day demo version of MarrowSoft
Xselerator.
I must confess - I think SVG is one of the greatest things since sliced bread! :-)
Combining the power of SVG with the capabilities of XSLT to produce dynamic graphics (e.g. graphs) from XML data is truly excellent - we just need to wait for SVG to be more widely supported by browsers (by default - at the moment it can only be done with the use of plug-ins, e.g. the Adobe SVG Viewer http://www.adobe.com/svg/viewer/install/main.html).
So I've been having a play with using SVG in combination with XSLT to produce some very rudimentary graphs and charts - this time it is the turn of the good old pie chart. I'm no SVG whiz so my SVG code may not be the best - and I'd appreciate comments if any experts out there can see that my SVG coding is way off beam!
The one thing that surprised me in SVG was the lack of the ability to specify arcs - without having to calculate the arc start and end positions. It would have been a lot nicer if arcs could be somehow specified by the center, angle and radius - or maybe I just missed something???
I have tried to make the actual template that draws each pie segment as isolated as possible - so this should be, to some degree, easily re-usable (feel free to lift it and make use of it in your own systems).
Anyway, my rudimentary attempts are shown below - do let me know what you think. NOTE: The full code (with included xsl library and example XML data is included in the source zip). Many thanks to Dimitre Novatchev for allowing me to use, in advance of its release, his trig library.
Cheers - Marrow http://www.MarrowSoft.com - home of Xselerator (XSLT IDE and debugger) http://www.TopXML.com/Xselerator
| Further additional information | |
Updating comments...
Updating comments...
|