#!/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 "
"; $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/X11/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||; } print "
Test chart
"; print end_html();