Added new scaling (1 tick/3 months) for series longer than 3 years.

This commit is contained in:
hjp 2003-04-24 14:39:01 +00:00
parent 185cbdedec
commit 03cb462f75
1 changed files with 27 additions and 2 deletions

View File

@ -4,7 +4,7 @@ use File::Temp qw(tempfile);
use Time::Local; use Time::Local;
use Data::Dumper; use Data::Dumper;
$VERSION = do { my @r=(q$Revision: 1.3 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r}; $VERSION = do { my @r=(q$Revision: 1.4 $=~/\d+/g);sprintf "%d."."%02d"x$#r,@r};
sub new { sub new {
my ($class, %opts) = @_; my ($class, %opts) = @_;
@ -117,7 +117,32 @@ sub plot {
my $firsttime = $self->{data}[0][0]; my $firsttime = $self->{data}[0][0];
my $lasttime = $self->{data}[$#{$self->{data}}][0]; my $lasttime = $self->{data}[$#{$self->{data}}][0];
if ($lasttime - $firsttime > 3 * 30 * 24 * 3600) { if ($lasttime - $firsttime > 3 * 365 * 24 * 3600) {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
$sec = $min = $hour = 0;
$mday = 1;
$mon = int($mon/3) * 3;
$firsttime = timelocal($sec,$min,$hour,$mday,$mon,$year);
print $ctlfh "set xtics rotate (";
my $comma = 0;
my $time;
for (;;) {
$time = timelocal($sec,$min,$hour,$mday,$mon,$year);
if ($comma) {
print $ctlfh ", ";
} else {
$comma = 1;
}
printf $ctlfh qq|"%04d-%02d-%02d" %d|, $year+1900, $mon+1, $mday, $time;
$mon += 3;
if ($mon >= 12) {
$mon -= 12; $year++;
}
if ($time > $lasttime) {last}
}
$lasttime = $time;
print $ctlfh ")\n";
} elsif ($lasttime - $firsttime > 3 * 30 * 24 * 3600) {
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($firsttime);
$sec = $min = $hour = 0; $sec = $min = $hour = 0;
$mday = 1; $mday = 1;