Added options style and timestamp.
This commit is contained in:
parent
c56fd5c9a0
commit
ec78df4a1d
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use Test::More tests => 11;
|
use Test::More tests => 12;
|
||||||
|
|
||||||
my $ps1=`./blib/script/tsplot --output_format ps t/1.data`;
|
my $ps1=`./blib/script/tsplot --output_format ps t/1.data`;
|
||||||
ok($ps1, 'Postscript output of tsplot is not empty');
|
ok($ps1, 'Postscript output of tsplot is not empty');
|
||||||
|
@ -27,8 +27,11 @@ ok($ps3 !~ m/\( 0\) Rshow/, 'Postscript output of tsplot doesn\'t contain marker
|
||||||
ok($ps3 =~ m/\( 1\) Rshow/, 'Postscript output of tsplot contains marker "1"');
|
ok($ps3 =~ m/\( 1\) Rshow/, 'Postscript output of tsplot contains marker "1"');
|
||||||
ok($ps3 =~ m/\( 10\) Rshow/, 'Postscript output of tsplot contains marker "10"');
|
ok($ps3 =~ m/\( 10\) Rshow/, 'Postscript output of tsplot contains marker "10"');
|
||||||
|
|
||||||
|
my $ps4=`./blib/script/tsplot --output_format ps --style dots t/1.data`;
|
||||||
|
ok($ps4, 'Postscript output of tsplot --style dots is not empty');
|
||||||
|
|
||||||
my $fh;
|
my $fh;
|
||||||
open($fh, ">", "t/$$.lin.ps"); print $fh $ps1; close($fh);
|
open($fh, ">", "t/$$.lin.ps"); print $fh $ps1; close($fh);
|
||||||
open($fh, ">", "t/$$.log.ps"); print $fh $ps3; close($fh);
|
open($fh, ">", "t/$$.dot.ps"); print $fh $ps4; close($fh);
|
||||||
|
|
||||||
#vim:tw=0
|
#vim:tw=0
|
||||||
|
|
14
tsplot
14
tsplot
|
@ -14,6 +14,7 @@ tsplotv
|
||||||
[--output-format format ]
|
[--output-format format ]
|
||||||
[--stacked]
|
[--stacked]
|
||||||
[--style style]
|
[--style style]
|
||||||
|
[--time_t]
|
||||||
[file ...]
|
[file ...]
|
||||||
|
|
||||||
=head1 DESCRIPTION
|
=head1 DESCRIPTION
|
||||||
|
@ -37,11 +38,19 @@ output formats, and styles.
|
||||||
The --stacked option causes the time series to be stacked on top of each
|
The --stacked option causes the time series to be stacked on top of each
|
||||||
other.
|
other.
|
||||||
|
|
||||||
|
The --time_t option specifies that the timestamps are in seconds since
|
||||||
|
the epoch. Otherwise they are parsed by add_timestring function (which
|
||||||
|
in turn uses the parse_date function of the HTTP::Date module).
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
my $output_format ='png';
|
my $output_format ='png';
|
||||||
my $log_y =0;
|
my $log_y =0;
|
||||||
|
my $time_t =0;
|
||||||
|
my $style = "lines";
|
||||||
GetOptions('output_format|output-format=s' => \$output_format,
|
GetOptions('output_format|output-format=s' => \$output_format,
|
||||||
'log_y|log-y' => \$log_y,
|
'log_y|log-y' => \$log_y,
|
||||||
|
'time_t' => \$time_t,
|
||||||
|
'style:s' => \$style,
|
||||||
)
|
)
|
||||||
or die "Usage: $0 [--output_format format] [files...]\n";
|
or die "Usage: $0 [--output_format format] [files...]\n";
|
||||||
|
|
||||||
|
@ -57,9 +66,14 @@ while (<>) {
|
||||||
}
|
}
|
||||||
while (<>) {
|
while (<>) {
|
||||||
my ($timestamp, @values) = split();
|
my ($timestamp, @values) = split();
|
||||||
|
if ($time_t) {
|
||||||
|
$ts->add($timestamp, @values);
|
||||||
|
} else {
|
||||||
$ts->add_timestring($timestamp, @values);
|
$ts->add_timestring($timestamp, @values);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$ts->log_y($log_y);
|
$ts->log_y($log_y);
|
||||||
|
$ts->style($style);
|
||||||
|
|
||||||
my $g = $ts->plot();
|
my $g = $ts->plot();
|
||||||
print $g
|
print $g
|
||||||
|
|
Loading…
Reference in New Issue