--- db2gantt.cgi 2002/09/13 14:34:02 1.9 +++ db2gantt.cgi 2002/09/13 18:35:50 1.11 @@ -5,6 +5,7 @@ use Data::Dumper; use Date::Parse; use CGI qw/:standard/; +use CGI::Carp qw(fatalsToBrowser); use POSIX qw(strftime); my $debug = 0; @@ -119,11 +120,48 @@ 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"; +# 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 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)); @@ -138,23 +176,10 @@ print STDERR "fix_d: $fix_d\n" if ($debug); } - print STDERR "bar[$status] len:$l s scale:",($len_t/$width)," size:$size px
alt:$alt\n" if ($debug); + print STDERR "bar[$col] len:$l s scale:",($len_t/$width)," size:$size px
alt:$alt\n" if ($debug); - my $html = "url(-relative=>1)."?pic="; - - if ($status) { - if ($cols{$status}) { - $html .= $cols{$status}; - } else { - $html .= "0,0,0"; # unknown status, black - } - $count{$status}++; - } else { -# $html .= '240,240,240'; - $html .= '220,220,220'; - } + my $html = "url(-relative=>1)."?pic=$col\" width=\"$size\" height=\"$height\""; - $html .= "\" width=\"$size\" height=\"$height\""; if ($use_js && $alt) { $html .= " onmouseover=\"T('$alt')\" onmouseout=\"T()\""; } elsif ($alt) { @@ -255,7 +280,9 @@ undef $sth; $dbh->disconnect; -print "\n"; +print "\n"; +hour_grid(); +print ""; # label and usage