Specification | ";
print mknav(($from_t-$int_t),$to_t,'<<'),$from;
print mknav(($from_t+$int_t),$to_t,'>>') if ($from_t+$int_t < $to_t);
@@ -119,15 +120,60 @@
print mknav($from_t,($to_t-$int_t),'<<') if ($to_t-$int_t > $from_t);
print $to,mknav($from_t,($to_t+$int_t),'>>')," |
\n";
-my $fix_d = 0; # used to fix graph len
+# draw hour grid
+sub hour_grid {
+ print "hour grid | ";
+ my @c = ("255,255,128","255,192,128");
+ my $hr=strftime("%H",localtime ($from_t));
+ print color_bar(3600 - $from_t % 3600,$c[0],sprintf("%02d",$hr++ % 24));
+ for (my $i=1; $i |
\n";
+}
+
+hour_grid();
+
+my $fix_d = 0; # used to fix graph len (in pixels)
+my $fix_s = 0; # used to collect round errors of size
sub bar {
- my $l = shift @_; # lenght of event utime
- my $status = shift @_ || undef; # what to draw
+ my $l = shift @_;
+ my $status = shift @_;
+ my $alt = shift @_;
+
+ my $col;
+
+ if ($status) {
+ if ($cols{$status}) {
+ $col .= $cols{$status};
+ } else {
+ $col .= "0,0,0"; # unknown status, black
+ }
+ $count{$status}++;
+ } else {
+# $col .= '240,240,240';
+ $col .= '220,220,220';
+ }
+ return color_bar($l,$col,$alt);
+}
+
+sub color_bar {
+ my $l = shift @_; # lenght of event utime
+ my $col = shift @_ || '240,240,240'; # default color (filler)
my $alt = shift @_ || undef;
- my $size = int($l / ($len_t / $width));
- if ($size < $min_l) {
+ my $size = $l / ($len_t / $width);
+ $fix_s += $size - int($size);
+ $size=int($size);
+ if ($fix_s > 1) {
+ $fix_s -= 1;
+ $size++;
+ }
+
+ if ($alt && $size < $min_l) {
$fix_d += ($min_l - $size);
print STDERR "fix_d: $fix_d\n" if ($debug);
$size = $min_l;
@@ -138,23 +184,10 @@
print STDERR "fix_d: $fix_d\n" if ($debug);
}
- print STDERR "bar[$status] len:$l s scale:",($len_t/$width)," size:$size px