waldo has asked for the wisdom of the Perl Monks concerning the following question:
A while back I stumbled across Tim Bunce's Treemap blog and thought I'd have a go at producing an SVG output module based on the Treemap module.
I want to produce a version that drills down through the data revealing more detail at each level. To do this I need to produce an hierarchical SVG document. But the existing Treemap module only passes on drawing data (coordinates, colour and text) when invoking the output objects methods.
Example of use below:
Input data:
<children name="main" size="6" colour="antiquewhite"> <children name="Treemap" size="4" colour="#FF0000"> <children name="xmlify" size="2" colour="#00FF00" /> <children name="save01" size="2" colour="#00FF00" link="save01.ht +ml" /> </children> <children name="Treemap::Output::SVG" size="6" colour="#FFFF00" > <children name="rect" size="1" colour="#00FFFF" /> <children name="text01" size="4" colour="whitesmoke"> <children name="text02" size="2" colour="#00FF00" > <children name="text02_01" size="1" colour="#F0F0F0" /> <children name="text02_02" size="1" colour="#F0F0F0" /> </children> <children name="text03" size="1" colour="#00FF00" /> <children name="text04" size="1" colour="cyan" /> </children> <children name="save02" size="1" colour="gray" /> </children> </children>
Creating an SVG output file:
use Treemap; use Treemap::Input::XML; use Treemap::Output::SVG; # read the XML input file my $in = Treemap::Input::XML->new(); $in->load( "inputfile.xml" ); my $out = Treemap::Output::SVG->new(); my $treemap = Treemap->new( INPUT=>$in, OUTPUT=>$out); # create a treemap in SVG using the XML input file provided $treemap->map(); # save the results to a file $out->save( "outputfile.svg" );
|
|---|