#!/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") || die $!;; 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); }