added the --tsv and --stacked options.
Use Pod::Usage to keep usage message in sync with pod.
This commit is contained in:
parent
2a5e204878
commit
43d3fed888
19
tsplot
19
tsplot
|
@ -2,6 +2,7 @@
|
|||
use strict;
|
||||
use TimeSeries;
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
|
||||
=head1 NAME
|
||||
|
||||
|
@ -15,6 +16,7 @@ tsplotv
|
|||
[--stacked]
|
||||
[--style style]
|
||||
[--time_t]
|
||||
[--tsv]
|
||||
[file ...]
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
@ -22,7 +24,8 @@ tsplotv
|
|||
This program expects time series data in column format, I.e.,
|
||||
each line contains a timestamp and the values for each series, except
|
||||
the first one which contains the column headers, which are used for the
|
||||
legend. Columns are separated by any amount of whitespace.
|
||||
legend. Columns are separated by any amount of whitespace unless the
|
||||
--tsv option is given which enables tab-separated columns.
|
||||
|
||||
The default legend position is "top right", same as with gnuplot.
|
||||
Another frequently useful position (especially if you have lots of series)
|
||||
|
@ -47,25 +50,32 @@ my $output_format ='png';
|
|||
my $log_y =0;
|
||||
my $time_t =0;
|
||||
my $style = "lines";
|
||||
my $tsv = 0;
|
||||
my $stacked = 0;
|
||||
GetOptions('output_format|output-format=s' => \$output_format,
|
||||
'log_y|log-y' => \$log_y,
|
||||
'time_t' => \$time_t,
|
||||
'style:s' => \$style,
|
||||
'tsv' => \$tsv,
|
||||
'stacked' => \$stacked,
|
||||
)
|
||||
or die "Usage: $0 [--output_format format] [files...]\n";
|
||||
or pod2usage(verbose => 0);
|
||||
|
||||
my $sep = $tsv ? qr/\t/ : ' ';
|
||||
|
||||
binmode STDOUT, ':raw';
|
||||
|
||||
my $ts = TimeSeries->new(output_format => $output_format);
|
||||
while (<>) {
|
||||
my @legend = split;
|
||||
chomp;
|
||||
my @legend = split($sep);
|
||||
shift @legend; # first must be for timestamp
|
||||
$ts->legend(@legend);
|
||||
last;
|
||||
}
|
||||
while (<>) {
|
||||
my ($timestamp, @values) = split();
|
||||
chomp;
|
||||
my ($timestamp, @values) = split($sep);
|
||||
if ($time_t) {
|
||||
$ts->add($timestamp, @values);
|
||||
} else {
|
||||
|
@ -74,6 +84,7 @@ while (<>) {
|
|||
}
|
||||
$ts->log_y($log_y);
|
||||
$ts->style($style);
|
||||
$ts->stacked($stacked);
|
||||
|
||||
my $g = $ts->plot();
|
||||
print $g
|
||||
|
|
Loading…
Reference in New Issue