Added some options to scripts and simple testcases for scripts.
This commit is contained in:
parent
d1284de05d
commit
690629d95f
|
@ -0,0 +1,4 @@
|
|||
date val1 val2
|
||||
2006-06-01 1 4
|
||||
2006-07-01 2 1
|
||||
2006-08-01 4 0
|
|
@ -0,0 +1,6 @@
|
|||
2006-06-01 val1 1
|
||||
2006-06-01 val2 4
|
||||
2006-07-01 val1 2
|
||||
2006-07-01 val2 1
|
||||
2006-08-01 val1 4
|
||||
2006-08-01 val2 0
|
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/perl
|
||||
use warnings;
|
||||
use strict;
|
||||
use Test::More tests => 7;
|
||||
|
||||
my $ps1=`./blib/script/tsplot --output_format ps t/1.data`;
|
||||
ok($ps1, 'Postscript output of tsplot is not empty');
|
||||
ok($ps1 =~ m/\(2006-06-04\) Rshow/, 'Postscript output of tsplot contains a date');
|
||||
ok($ps1 =~ m/\(val1\) Rshow/, 'Postscript output of tsplot contains a column name');
|
||||
|
||||
my $ps2=`./blib/script/tsplotv --output_format ps t/1.vdata`;
|
||||
ok($ps2, 'Postscript output of tsplot is not empty');
|
||||
ok($ps2 =~ m/\(2006-06-04\) Rshow/, 'Postscript output of tsplot contains a date');
|
||||
ok($ps2 =~ m/\(val1\) Rshow/, 'Postscript output of tsplot contains a column name');
|
||||
|
||||
# title and creation date will be different, but the rest should be
|
||||
# identical:
|
||||
$ps1 =~ s/^%%Title: .*//m;
|
||||
$ps1 =~ s/^%%CreationDate: .*//m;
|
||||
$ps2 =~ s/^%%Title: .*//m;
|
||||
$ps2 =~ s/^%%CreationDate: .*//m;
|
||||
ok($ps1 eq $ps2, 'output of tsplot and tsplotv are identical');
|
||||
|
||||
#vim:tw=0
|
8
tsplot
8
tsplot
|
@ -1,10 +1,16 @@
|
|||
#!/usr/bin/perl -w
|
||||
use strict;
|
||||
use TimeSeries;
|
||||
use Getopt::Long;
|
||||
|
||||
my $output_format ='png';
|
||||
GetOptions('output_format|output-format=s' => \$output_format)
|
||||
or die "Usage: $0 [--output_format format] [files...]\n";
|
||||
|
||||
|
||||
binmode STDOUT, ':raw';
|
||||
|
||||
my $ts = TimeSeries->new();
|
||||
my $ts = TimeSeries->new(output_format => $output_format);
|
||||
while (<>) {
|
||||
my @legend = split;
|
||||
shift @legend; # first must be for timestamp
|
||||
|
|
16
tsplotv
16
tsplotv
|
@ -13,6 +13,16 @@ each line contains a tripel <time, series, value>.
|
|||
|
||||
use strict;
|
||||
use TimeSeries;
|
||||
use Getopt::Long;
|
||||
|
||||
my $output_format ='png';
|
||||
my $stacked = 0;
|
||||
my $legend_position = 'top right';
|
||||
GetOptions('output_format|output-format=s' => \$output_format,
|
||||
'stacked' => \$stacked,
|
||||
'legend_position|legend-position=s' => \$legend_position,
|
||||
) or die "Usage: $0 [--output_format format] [files...]\n";
|
||||
|
||||
|
||||
binmode STDOUT, ':raw';
|
||||
|
||||
|
@ -20,7 +30,7 @@ my %series;
|
|||
my $ns;
|
||||
my %data;
|
||||
|
||||
my $ts = TimeSeries->new();
|
||||
my $ts = TimeSeries->new(output_format => $output_format);
|
||||
while (<>) {
|
||||
chomp;
|
||||
my ($timestamp, $series, $value) = split(/\t/);
|
||||
|
@ -29,8 +39,8 @@ while (<>) {
|
|||
}
|
||||
my @series = sort { $series{$a} <=> $series{$b} } keys %series;
|
||||
$ts->legend(@series);
|
||||
$ts->legend_position("below");
|
||||
$ts->stacked(1);
|
||||
$ts->legend_position($legend_position);
|
||||
$ts->stacked($stacked);
|
||||
for my $timestamp (sort keys %data) {
|
||||
my %d = %{$data{$timestamp}};
|
||||
my @values = @d{@series};
|
||||
|
|
Loading…
Reference in New Issue