use style "filledcurves" for stacked data.

This commit is contained in:
hjp 2011-04-03 08:04:55 +00:00
parent cec6895a09
commit 94091963d4
1 changed files with 19 additions and 5 deletions

View File

@ -33,7 +33,7 @@ use HTTP::Date qw(parse_date);
use Time::Local qw(timegm_nocheck); use Time::Local qw(timegm_nocheck);
use POSIX qw(strftime); 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; our $debug;
@ -348,8 +348,12 @@ sub plot {
print $datafh $time; print $datafh $time;
if ($self->{stacked}) { if ($self->{stacked}) {
my $v = 0; my $v = 0;
for my $j (@$data) { my @stackeddata;
$v += ($j || 0); for (my $j = $#$data; $j >= 0; $j--) {
$v += ($data->[$j] || 0);
$stackeddata[$j] = $v;
}
for my $v (@stackeddata) {
print $datafh "\t", $v; print $datafh "\t", $v;
} }
} else { } else {
@ -366,7 +370,11 @@ sub plot {
# generic settings # 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 output '$psfn'\n";
print $ctlfh "set style data $self->{style}\n"; print $ctlfh "set style data $self->{style}\n";
print $ctlfh "set grid\n"; print $ctlfh "set grid\n";
@ -397,7 +405,11 @@ sub plot {
} else { } else {
$comma = 1; $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"; print $ctlfh "\n";
@ -412,6 +424,8 @@ sub plot {
if ($self->{output_format} eq "ps") { if ($self->{output_format} eq "ps") {
$pipe = "< $psfn"; $pipe = "< $psfn";
} elsif ($self->{output_format} eq "svg") {
$pipe = "< $psfn";
} else { } else {
$pipe = "gs -sDEVICE=ppmraw -r" . $self->{gsresolution} . " -dBATCH -sOutputFile=- -q - < $psfn |"; $pipe = "gs -sDEVICE=ppmraw -r" . $self->{gsresolution} . " -dBATCH -sOutputFile=- -q - < $psfn |";
if ($self->{gsresolution} != $self->{finalresolution}) { if ($self->{gsresolution} != $self->{finalresolution}) {