timeseries/tsplotv

42 lines
833 B
Perl
Executable File

#!/usr/bin/perl -w
=head1 NAME
tsplotv - plot time series given in vertical format
=head1 DESCRIPTION
This program expects time series data in vertical format, I.e.,
each line contains a tripel <time, series, value>.
=cut
use strict;
use TimeSeries;
binmode STDOUT, ':raw';
my %series;
my $ns;
my %data;
my $ts = TimeSeries->new();
while (<>) {
chomp;
my ($timestamp, $series, $value) = split(/\t/);
$series{$series} = ++$ns unless ($series{$series});
$data{$timestamp}{$series} = $value;
}
my @series = sort { $series{$a} <=> $series{$b} } keys %series;
$ts->legend(@series);
$ts->legend_position("below");
$ts->stacked(1);
for my $timestamp (sort keys %data) {
my %d = %{$data{$timestamp}};
my @values = @d{@series};
$ts->add_timestring($timestamp, @values);
}
my $g = $ts->plot();
print $g