Monday, January 29, 2007

Simple perl program to create 3d graph using GD::Graph




#!/usr/bin/perl -w
$++;
use strict;
use GD::Graph::bars;
#Following data illustrated on GD::Graph module



my @data = ( ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
[ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
[ sort { $a <=> $b } (1, 2, 5, 6, 3, 1.5, 1, 3, 4) ] );
my $graph = GD::Graph::bars->new(300, 200);
$graph->set( x_label => 'X Label',
y_label => 'Y label',
title => 'Some simple graph',
y_max_value => 8,
y_tick_number => 8,
y_label_skip => 2 );
my $gd = $graph->plot(\@data);
print "content-type: image/png\n\n";
binmode STDOUT;
print $gd->png;

This should have created a nice graph line chart.
See the script in action at my web page

Monday, January 15, 2007

Requirement

Requirements for 3D graph perl programs:
Perl itself, Lincoln Stein's GD module, (specifically GD, GD::Graph). Fctrl, CGI, GD::Text are optional. Check your server if these modules are already installed or you have to install them yourself.

Wednesday, January 10, 2007

3D Graph Perl

Would you like to write or use perl program that creates 3D graph images online? I am going to attempt to demonstrate and write a perl script that would generate graph charts on-line. GD::Graph module will be dissected as part of creating 3D graph. I searched the web for a perl script that would generate charts online but unsucessful. I have a working 3D Perl Survey Script. I don't have a formal c.s. training thus excuse my unorthodox style.