Revision 215
- Date:
- 2009/11/22 17:12:27
- Files:
Legend:
- Added
- Removed
- Modified
-
trunk/bin/install-debian.sh
1 1 #!/bin/sh -x 2 2 3 sudo apt-get install libdata-dump-perl libfile-slurp-perl libberkeleydb-perl 3 sudo apt-get install libdata-dump-perl libfile-slurp-perl libberkeleydb-perl \ 4 gnuplot -
trunk/lib/Sack/Server/Gnuplot.pm
1 package Sack::Server::Gnuplot; 2 3 use warnings; 4 use strict; 5 6 use Chart::Gnuplot; 7 use Data::Dump qw(dump); 8 9 sub date { 10 my ( $x, $y, $path ) = @_; 11 12 $path ||= '/tmp/date.png'; 13 14 # Create the chart object 15 my $chart = Chart::Gnuplot->new( 16 output => $path, 17 xlabel => 'Date axis', 18 timeaxis => "x", # declare that x-axis uses time format 19 ); 20 21 # Data set object 22 my $data = Chart::Gnuplot::DataSet->new( 23 xdata => $x, 24 ydata => $y, 25 style => 'linespoints', 26 timefmt => '%Y-%m-%d', # input time format 27 ); 28 29 # Plot the graph 30 $chart->plot2d($data); 31 32 warn "gnuplot $path ", -s $path, " bytes\n"; 33 34 return $path; 35 } 36 37 1; -
trunk/Makefile.PL
14 14 -default => 0, 15 15 'Net::Ping', 16 16 ], 17 'Sack::Server::Graph' => [ 18 -default => 0, 19 'Chart::Gnuplot', 20 ], 17 21 ); 18 22 19 23 build_requires 'Test::More'; -
trunk/t/Sack-Server-Gnuplot.t
1 #!/usr/bin/perl 2 3 use Test::More tests => 2; 4 use File::Slurp; 5 use Data::Dump qw(dump); 6 7 use lib '/srv/Sack/lib'; 8 9 BEGIN { 10 use_ok( 'Sack::Server::Gnuplot' ); 11 } 12 13 my @x = qw( 14 2009-11-22 15 2009-11-08 16 2009-11-02 17 2009-10-15 18 ); 19 20 ok( my $path = Sack::Server::Gnuplot::date( \@x, [ 0 .. $#x ] ), 'date' ); 21 ok( -e $path, "$path exists" );