#!/usr/bin/perl use strict; use warnings; use Data::Dumper 'Dumper'; use GD::Graph::linespoints; my @month = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my $data= [ [ '1155279600', '1156366000', '1157452400', ], [ '88', '93', '23', ] ]; my %arg = ( marker_size => 1, x_label => 'Date', x_min_value => $data->[0]->[0], x_max_value => $data->[0]->[-1], x_tick_number => 7, x_tick_offset => 1, x_number_format => \&convert_date, y_label => 'Inventory Count', y_tick_number => 5, ); # create graph my $graph = GD::Graph::linespoints->new(750,450); $graph->set(%arg) or die $graph->error.Dumper(\%arg); my $gd = $graph->plot($data) or die $graph->error.Dumper($data); # write graph to disk open(my $graphfile, '>', "/home/clive/public_html/tmp2.png") || di +e $!;; binmode $graphfile; print {$graphfile} $gd->png; close($graphfile); sub convert_date { my $epoch_time = shift; my @t = localtime($epoch_time); return sprintf("%02d %s %d", $t[3], $month[ $t[4] ], $t[5]+1900); }
Creating this image. However, if I switch to GD::Graph::area (which is what I need to use), I get this empty one.
If I then change the data to this:
my $data= [ [ '1', '2', '3', ], [ '1', '2', '3', ] ];
I get a real graph.
No error messages appear at all. I've been scratching my head on this one for an hour. Anyone got any idea what's up?
In reply to GD::Graph::area failing with no error... by cLive ;-)
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |