ptum has asked for the wisdom of the Perl Monks concerning the following question:
It has been some time since I last needed to dynamically create a bar or line chart from an arbitrary data source (in my case a database of network configuration events). Several years back I used Martien Verbruggen's GIFgraph module -- I see he has moved on to GD::Graph. Has a clear leader in terms of usability and attractive functionality emerged among the CPAN graph and chart modules?
UPDATE: Thanks to all those who responded; I checked out GD::Graph3d and found it very much to my liking. I decided to rebuild libgd on my Solaris 5.9 system to include the libpng and FreeType libraries, and I had quite a bit of difficulty before I realized that I needed to provide the LD_LIBRARY_PATH environment variable to my CGI script in order for it to find the proper GD libraries to produce the PNG images. I hadn't realized that environment variables need to be explicitly passed or set within Apache http://httpd.apache.org/docs/1.3/env.html. I ended up with dynamically-generated PNG images with support for TrueType fonts, which pleases me greatly. Here's a simple test script that produces a 3d bar, 3d line and pie chart from sample data, if anyone is interested:
UPDATE: Thanks to all those who responded; I checked out GD::Graph3d and found it very much to my liking. I decided to rebuild libgd on my Solaris 5.9 system to include the libpng and FreeType libraries, and I had quite a bit of difficulty before I realized that I needed to provide the LD_LIBRARY_PATH environment variable to my CGI script in order for it to find the proper GD libraries to produce the PNG images. I hadn't realized that environment variables need to be explicitly passed or set within Apache http://httpd.apache.org/docs/1.3/env.html. I ended up with dynamically-generated PNG images with support for TrueType fonts, which pleases me greatly. Here's a simple test script that produces a 3d bar, 3d line and pie chart from sample data, if anyone is interested:
#!/usr/local/bin/perl -w use GD::Graph::bars3d; use GD::Graph::lines3d; use GD::Graph::pie3d; use CGI qw/:standard :html3 center/; use CGI::Carp qw(fatalsToBrowser); use strict; print header; print start_html(-title=>"3D Graph Test"); my @data = ( ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], [ 1203, 3500, 3973, 2859, 3012, 3423, 1230], [ 819, 2500, 4901, 429, 1604, 2199, 700], [ 4412, 1500, 2211, 1394, 4501, 2290, 50], ); my @graphs = (); my $width=300; my $height=200; print "<center><table border=0 cellpadding=10 cellspacing=10><tr>"; $graphs[0] = new GD::Graph::bars3d( $width, $height ); $graphs[1] = new GD::Graph::lines3d( $width, $height ); $graphs[2] = new GD::Graph::pie3d( $width, $height ); $graphs[0]->set ( bar_depth => 10, bar_spacing => 10, overwrite => 2, cumulate => 1, shading => 1 ); $graphs[1]->set ( line_depth => 5, shading => 3 ); for (my $i=0;$i<3;$i++) { $graphs[$i]->set ( x_label => 'Day of the week', y_label => 'Number of hits', zero_axis => 1, box_axis => 0, title => 'Daily Summary of Web Site', ); $graphs[$i]->set_legend("Frank", "Bob", "Sue"); $graphs[$i]->set_title_font('/usr/openwin/lib/locale/iso_8859_13/X +11/fonts/TrueType/LucidaTypewriterBoldOblique.ttf', 8+$i*2); $graphs[$i]->set_legend_font(GD::Text::gdTinyFont); my $timeval = time() + $i; my $gd = $graphs[$i]->plot( \@data ); my $image_stream = $gd->png(); unless (open(GRAPH,">/up/web/data/testgraph${timeval}.png")) { die "Can't open /up/web/data/testgraph${timeval}.png: $!"; } print GRAPH $image_stream; close(GRAPH); print qq|<td><img src="../data/testgraph${timeval}.png" alt="Test +chart"></td>|; } print "</tr></table></center>"; print end_html();
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Charting Modules
by samtregar (Abbot) on Nov 14, 2005 at 19:29 UTC | |
Re: Charting Modules
by diotalevi (Canon) on Nov 14, 2005 at 20:28 UTC | |
by Tomte (Priest) on Nov 14, 2005 at 22:22 UTC | |
Re: Charting Modules
by BerntB (Deacon) on Nov 14, 2005 at 19:46 UTC | |
by 5mi11er (Deacon) on Nov 15, 2005 at 19:30 UTC | |
by BerntB (Deacon) on Nov 16, 2005 at 10:12 UTC | |
by 5mi11er (Deacon) on Nov 16, 2005 at 15:37 UTC | |
Re: Charting Modules
by davorg (Chancellor) on Nov 15, 2005 at 10:54 UTC | |
Re: Charting Modules
by dragonchild (Archbishop) on Nov 15, 2005 at 00:45 UTC | |
Re: Charting Modules
by zentara (Archbishop) on Nov 15, 2005 at 12:56 UTC |
Back to
Seekers of Perl Wisdom