An XSLT program to render numerical data as SVG charts.
Put your numbers in a simple XML structure and run svgchart.xslt on your XML file to get an SVG graphic.
svgchart.xslt was tested with Saxon 6.5.3. Currently only one kind of chart is supported:
To render percentages as a pie chart, you have to generate an XML instance like pie.xml. It looks like this:
Run svgchart.xslt on your XML and you get pie.svg.
View the SVG in your favourite SVG viewer or rasterize it as a bitmap. For example, using Batik:
java -jar batik-rasterizer.jar pie.svg
The resulting pie.png:
SVG Charts is just a tiny demonstration project. I'd like it to support more chart types (i.e. bar charts and more), 3D charts, animations etc., but since I don't get money from the project I can't spend too much time. If you're interested in other chart types, you should (a) implement them on yourself or (b) check back every few month; BTW: I will post updates in our News.
I will add an XML and Relax NG schema for the input XML. For now, here's a DTD, that does not care about the Namespace. Use the DTD just for your information, not to validate the input XML:
<!ELEMENT chart (pie)> <!ELEMENT pie (segment+)> <!ATTLIST pie width CDATA #REQUIRED height CDATA #REQUIRED> <!ELEMENT segment (#PCDATA)> <!ATTLIST segment color CDATA #REQUIRED>
Last, but not least: The program was written by me, Stefan Mintert. It's copyrighted. If you want to use it, read the licence.
Thanks to Thomas Meinike for fixing a bug with segments greater 180 degrees. More about segments of circles with JavaScript on Thomas' SVG site.
Stefan Mintert, $Date: 2005/06/16 10:26:50 $