diff --git a/TimeSeries.pm b/TimeSeries.pm index fff1ad0..e429a7e 100644 --- a/TimeSeries.pm +++ b/TimeSeries.pm @@ -27,7 +27,7 @@ use Data::Dumper; use HTTP::Date qw(parse_date); use Time::Local qw(timegm_nocheck); -$VERSION = do { my @r=(q$Revision: 1.13 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r}; +$VERSION = do { my @r=(q$Revision: 1.14 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r}; =head2 new(%opts) @@ -330,7 +330,7 @@ sub plot { } } else { for my $j (@$data) { - print $datafh "\t", ($j || 0) + 0; + print $datafh "\t", (defined $j ? $j : '?'); } } print $datafh "\n"; @@ -349,6 +349,7 @@ sub plot { print $ctlfh "set log x\n" if ($self->{log_x}); print $ctlfh "set log y\n" if ($self->{log_y}); print $ctlfh "set key $self->{legend_position}\n" if ($self->{legend_position}); + print $ctlfh "set datafile missing '?'\n"; # compute ticks @@ -522,7 +523,7 @@ sub plot { } else { $comma = 1; } - print $ctlfh "'$datafn' using 1:", $col++, " title '$i'"; + print $ctlfh "'$datafn' using 1:(\$", $col++, ") title '$i'"; } print $ctlfh "\n"; diff --git a/t/3missing.t b/t/3missing.t new file mode 100644 index 0000000..aace333 --- /dev/null +++ b/t/3missing.t @@ -0,0 +1,41 @@ +#!/usr/bin/perl +use warnings; +use strict; +use Test::More tests => 3; + +BEGIN { use_ok( 'TimeSeries' ); } + + +my $ts = TimeSeries->new(output_format => 'ps'); +ok($ts, 'create timeseries'); +$ts->add(0, 100); +$ts->add(1000, 200); +$ts->add(2000, 100); +$ts->add(3000, undef); +$ts->add(4000, 100); +$ts->add(5000, 200); +$ts->add(6000, 100); +$ts->legend('missing'); +my $p = $ts->plot(); +my $t = "LT0 +6395 4739 M +399 0 V +574 1344 M +1639 4872 L +2703 1344 L +2130 0 R +5897 4872 L +6962 1344 L +1.000 UL +LTb +574 1344 M +6388 0 V +0 3528 V +-6388 0 V +0 -3528 V +1.000 UP +stroke"; +ok(index($p, $t) != -1, 'postscript output looks ok'); + +#vim:tw=0 +