[cricket-users] grapher.cgi question 2nd try

From: Neal S. Pressman (nsp83273@melsud.res.ray.com)
Date: Fri Jul 23 1999 - 06:19:58 PDT


From: "Neal S. Pressman" <nsp83273@melsud.res.ray.com>

i didnt recieve any responses from my first post so in case it never
made it out to the list here it is again:

when i first installed ver 0.63 i had made some changes to grapher.cgi

to add in a description to the top of the image and to change the
background color:

        '--color', "CANVAS\#c0c0c0",
        '--title', "$targRef->{'long-desc'}",

i simply added them into @args

i also added in:

        $xaxiscmd, $xaxis,

this was defined in the same code as the $vruleColor and $rangeType

here is my code from version 0.63:

#RANGE#
        my($vruleColor) = graphParam('vrule-color', undef, undef);
        my($xaxis) = "MINUTE:60:HOUR:2:HOUR:2:0:\%H";
        my($xaxiscmd) = "--x-grid";
        my(@vrules);
        if (defined($vruleColor) and $vruleColor ne 'none') {
                $vruleColor = colorToCode($vruleColor);

                my($rangeType) = rangeType($range);

                # first, find the time of the most recent zero mark
                my($timeToZeroTime) = 0;
                my($deltaZeroTime) = 0; # the number of seconds between zero times
                my($now) = time();
                my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now);

                # find out how many seconds we are past the last zero time
                $timeToZeroTime += $sec;
                $timeToZeroTime += $min * 60;
                $timeToZeroTime += $hour * 60 * 60;
                $deltaZeroTime = 60 * 60 * 24;

                if ($rangeType == $main::kTypeWeekly) {
                        my($numDaysToMonday) = ($wday - 1);
                        $timeToZeroTime += $numDaysToMonday * 60 * 60 * 24;
                        $deltaZeroTime *= 7;
        $xaxis = "HOUR:6:HOUR:24:DAY:1:86400:\%a";
                }
                if ($rangeType == $main::kTypeMonthly) {
                        $timeToZeroTime += ($mday - 1) * 60 * 60 * 24;
                        $deltaZeroTime *= 30;
        $xaxis = "DAY:1:DAY:7:DAY:7:0:\%b_%d";
                }
                if ($rangeType == $main::kTypeYearly) {
                        $timeToZeroTime += $yday * 60 * 60 * 24;
                        # yikes... what about leap year? Ick.
                        $deltaZeroTime *= 365;
        $xaxis = "WEEK:1:MONTH:1:MONTH:1:18144000:\%b";
                }

the purpose of this change was to change how the information was outputed
on the image the syntax is taken straight from the RRDTOOL docs.

i have tried both 0.68 and 0.69 and neither will accept my $xaxis code
i takes the initial value and applys it to all rangetypes its almost as if
the if ($rangeType == code is never being executed

this is my current code from grapher.cgi in ver 0.69:

#RANGE#
        my($vruleColor) = graphParam($gRefDef, 'vrule-color', undef);
        my($xaxis) = "MINUTE:60:HOUR:2:HOUR:2:0:\%H";
        my($xaxiscmd) = "--x-grid";
        my(@vrules);
        if (defined($vruleColor) and $vruleColor ne 'none') {
                $vruleColor = colorToCode($colorRef, $vruleColor);

                my($rangeType) = rangeType($range);

                # first, find the time of the most recent zero mark
                my($timeToZeroTime) = 0;
                my($deltaZeroTime) = 0; # the number of seconds between zero times
                my($now) = time();
                my($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($now);

                # find out how many seconds we are past the last zero time
                $timeToZeroTime += $sec;
                $timeToZeroTime += $min * 60;
                $timeToZeroTime += $hour * 60 * 60;
                $deltaZeroTime = 60 * 60 * 24;

                if ($rangeType == $kTypeWeekly) {
                        my($numDaysToMonday) = ($wday - 1);
                        $timeToZeroTime += $numDaysToMonday * 60 * 60 * 24;
                        $deltaZeroTime *= 7;
        $xaxis = "HOUR:6:HOUR:24:DAY:1:86400:\%a";
                }
                if ($rangeType == $kTypeMonthly) {
                        $timeToZeroTime += ($mday - 1) * 60 * 60 * 24;
                        $deltaZeroTime *= 30;
        $xaxis = "DAY:1:DAY:7:DAY:7:0:\%b_%d";
                }
                if ($rangeType == $kTypeYearly) {
                        $timeToZeroTime += $yday * 60 * 60 * 24;
                        # yikes... what about leap year? Ick.
                        $deltaZeroTime *= 365;
        $xaxis = "WEEK:1:MONTH:1:MONTH:1:18144000:\%b";
                }
                my($zeroTime) = $now - $timeToZeroTime;

--
                                \\|//
                                (0~0)
----------------------------oooO-(_)-Oooo----------------------------
 Neal S. Pressman                        Raytheon Systems Company   
 Systems Administrator (C3i/EA)          528 Boston Post Road
 Phone:  (978) 440-1273                  Sudbury, MA  01776
 Fax:    (978) 440-2684                  Ms 4-1-283
 E-mail:  nsp@melsud.res.ray.com / Neal_S_Pressman@res.raytheon.com
____________________________________Oooo.____________________________
                             .oooO  (___)

--------------------------- ONElist Sponsor ----------------------------

ONElist members are using Shared Files in great ways! http://www.onelist.com Are you? If not, see our homepage for details.

------------------------------------------------------------------------



This archive was generated by hypermail 2b29 : Mon Mar 06 2000 - 19:00:58 PST