Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

GD::Graph skip_undef not working properly

by kryberg (Pilgrim)
on Oct 02, 2003 at 17:37 UTC ( [id://295982]=perlquestion: print w/replies, xml ) Need Help??

kryberg has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I’ve created a bunch of line graphs with GD and GD::Graph that update every 15 minutes. They are working well, with two exceptions. The first one perlmonks helped me fix here. The second problem is regarding undefined values. Occasionally there is an equipment malfunction and there is missing data. I’m checking for the missing data and inserting undef. Here’s an example:
484200023020000 2003-09-30 22:00 11.2 10.2 .65 .00 484200023020000 2003-09-30 22:15 11.2 10.3 .65 .00 484200023020000 2003-09-30 22:30 11.1 10.3 .65 .00 484200023020000 2003-09-30 22:45 11.1 10.3 .64 .00 484200023020000 2003-09-30 23:00 11.1 10.2 .64 .00 484200023020000 2003-09-30 23:15 undef undef undef undef 484200023020000 2003-09-30 23:30 undef undef undef undef 484200023020000 2003-09-30 23:45 undef undef undef undef 484200023020000 2003-10-01 00:00 undef undef undef undef 484200023020000 2003-10-01 00:15 undef undef undef undef 484200023020000 2003-10-01 00:30 undef undef undef undef 484200023020000 2003-10-01 00:45 undef undef undef undef 484200023020000 2003-10-01 01:00 undef undef undef undef 484200023020000 2003-10-01 01:15 10.9 10.2 .62 .00 484200023020000 2003-10-01 01:30 10.9 10.3 .62 .10
I have $graph->set(skip_undef=>1); in my program. The GD::Graph documentation says under Options for graphs with lines that “If skip_undef has a true value, there will be a gap in the chart where a Y value is undefined.” I am not getting a gap. What happens is that it plots the last defined value, draws a vertical line down to 0 on the y-axis, continues graphing at zero, then at the next defined value draws a vertical line back up the to the appropriate y-value, and continues graphing the rest of the values.

If I have warnings on I get Argument "undef" isn't numeric in numeric lt (<) at /usr/local/lib/perl5/site_perl/5.8.0/GD/Graph/Data.pm line 231. for every undef value. True, they aren’t numeric, but I just want them skipped.

I tried setting skip_undef=>0 just to see what happened. The points are supposed to get skipped, with the line being drawn between the defined points. I got the same result as with skip_undef=>1 – a line down to zero, then back up when points were defined again.

Any suggestions for fixing this?

Thanks

Replies are listed 'Best First'.
Re: GD::Graph skip_undef not working properly
by flounder99 (Friar) on Oct 02, 2003 at 19:41 UTC
    I think you are sending the string "undef" and not an undefined value. Try a
    @datapointsarray = map {$_ eq "undef" ? undef : $_ } @datapointsarray;
    on the array that holds your datapoints.

    --

    flounder

      It worked! That made my day!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://295982]
Approved by jdtoronto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-03-28 23:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found