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

In reply to GD::Graph skip_undef not working properly by kryberg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.