From 94091963d4c6a3871e55e095ca4d7dfc7845ed02 Mon Sep 17 00:00:00 2001 From: hjp Date: Sun, 3 Apr 2011 08:04:55 +0000 Subject: [PATCH] use style "filledcurves" for stacked data. --- TimeSeries.pm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/TimeSeries.pm b/TimeSeries.pm index 67812d8..bae3f9e 100644 --- a/TimeSeries.pm +++ b/TimeSeries.pm @@ -33,7 +33,7 @@ use HTTP::Date qw(parse_date); use Time::Local qw(timegm_nocheck); use POSIX qw(strftime); -our $VERSION = do { my @r=(q$Revision: 1.22 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r}; +our $VERSION = do { my @r=(q$Revision: 1.23 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r}; our $debug; @@ -348,8 +348,12 @@ sub plot { print $datafh $time; if ($self->{stacked}) { my $v = 0; - for my $j (@$data) { - $v += ($j || 0); + my @stackeddata; + for (my $j = $#$data; $j >= 0; $j--) { + $v += ($data->[$j] || 0); + $stackeddata[$j] = $v; + } + for my $v (@stackeddata) { print $datafh "\t", $v; } } else { @@ -366,7 +370,11 @@ sub plot { # generic settings - print $ctlfh "set term postscript color solid 10\n"; + if ($self->{output_format} eq 'svg') { + print $ctlfh "set term $self->{output_format}\n"; + } else { + print $ctlfh "set term postscript color solid 10\n"; + } print $ctlfh "set output '$psfn'\n"; print $ctlfh "set style data $self->{style}\n"; print $ctlfh "set grid\n"; @@ -397,7 +405,11 @@ sub plot { } else { $comma = 1; } - print $ctlfh "'$datafn' using 1:(\$", $col++, ") title '$i'"; + if ($self->{style} eq 'filledcurves') { + print $ctlfh "'$datafn' using 1:(\$", $col++, "):(0) title '$i'"; + } else { + print $ctlfh "'$datafn' using 1:(\$", $col++, ") title '$i'"; + } } print $ctlfh "\n"; @@ -412,6 +424,8 @@ sub plot { if ($self->{output_format} eq "ps") { $pipe = "< $psfn"; + } elsif ($self->{output_format} eq "svg") { + $pipe = "< $psfn"; } else { $pipe = "gs -sDEVICE=ppmraw -r" . $self->{gsresolution} . " -dBATCH -sOutputFile=- -q - < $psfn |"; if ($self->{gsresolution} != $self->{finalresolution}) {