Howdy: I think I need a second pair of eyes. I think I'm close with creating a trending line graph, but I can't figure out what part goes where and why I can not see anything useful.
My goal: I am trying to connect to the database and pull back 6 fields (5 regions and 1 timestamp) and chart the trends of the 5 regions BY the time they were entered. I want the results to be something close y_min_value=0 and y_max_value=800000 (which is does show); then I'd like to fix the 5 regions and do the 'connect the dot' for each timestamp (which should be the x axis line). THAT'S the part where I'm failing. The bottom doesn't show the multiple 'enter_dt' (timestamp), neither does it show the 5 regions (which I want to display in the graph from top to bottom (so, the highest point would be region the 'SE' that equates to about 700000 people, 'POS' equates to about 500000 people, and so on). Any suggestions / examples out there where I can figure out what I'm doing wrong? (Also, should I just cross-post go beginners-cgi?) Thanks! -X [snip script] #!/usr/bin/perl -w use diagnostics; use CGI; use GD::Graph::lines; use DBI; my $dbh=DBI->connect('dbi:Pg:dbname=testdb', 'joeuser') or die "Can not connect: $!"; # bu array ordered by time and date entered my $sql= qq| select se, pos, west, east, mid, enter_dt from t_mbr_trend order by enter_dt |; my $sth=$dbh->prepare($sql) or die "Error =", DBI::errstr; my $q = new CGI; my $graph = new GD::Graph::lines; #graph type and size # Syntaxerror should be arround here while ($row = $sth->fetchrow_array()) { ($se, $pos, $west, $east, $mid, $enter_dt) = @{$row}; push @se, $se; push @pos, $pos; push @west, $west; push @east, $east; push @mid, $mid; push @enter_dt, $enter_dt; } # gedaan $sth->finish; # your database array my @data = ([\@enter_dt], [ \@se, \@pos, \@west, \@east, \@mid ] ); $graph->set( title => "Membership Trend: Line Chart", x_label => "Date of Count", y_label => "Population", y_max_value => 800000, y_min_value => 0, y_tick_number => 10, box_axis => 1, line_width => 2, show_values => 1 ); $graph->set_legend("test member table"); my $gd_image = $graph->plot(\@data); print $q->header(-type => "image/png"); # start drinking the graph binmode STDOUT; # graph is in BINARY mode coz picture print $gd_image->png; # u can do jpg, gif, but this #is png format, you can change it. $dbh->disconnect; [/end of script]