#! c:/perl/bin/perl.exe -w use GD::Graph::bars; #having connected to the database and composed a query, $query my %outputs; $db->Sql("$query"); while ($db->FetchRow()) { @results = $db->Data ; $day = $results[0] ; $line = $results[1] ; $output = $results[2] ; $outputs{$line}{$day} = $output; } # create individual arrays of data foreach $key (keys %outputs) { foreach $key2 (sort keys %{ $outputs{$key}}) { print "key: $key \t key2: $key2 \t data: $outputs{$key}{$key2} \n"; push( @{$key}, $outputs{$key}{$key2}); $repeateddays{$key2}=$key2; } } # a hash with my days in (not very clever but neither am I) @days = (sort keys %repeateddays); # A visual check things have worked print "At canning = @CANNING \t quest = @QUEST \t MULTIPACK = @MULTIPACK \t days = @days\n"; # Put the data into a format GD::Graph likes @datatoplot = ( [@days], [@CANNING] ); # Set up and draw my graph my $mygraph3 = GD::Graph::bars->new(400, 250); $mygraph3->set( # some stuff ) or warn $mygraph3->error; my $myimage = $mygraph->plot(\@datatoplot) or die $mygraph3->error; $filename = "multi_layer_hash_development.png"; open (PRODGRAPHCUMU, ">c:/perl/bin/Durge/GD/" . $filename) ; # Make sure we are writing to a binary stream binmode PRODGRAPHCUMU; print PRODGRAPHCUMU $myimage->png; exit 0; # Voila I have a pretty graph!