So, I'm still plugging away to see why my arrays won't graph, and I ran into something that's rather curious to me, and I can't see where the issue lies.

The following code creates a small graph with three lines plotted:

use GD::Graph::lines; $Group = "Test Group"; #@name1 = ; #@name2 = ; #@name3 = ; #@xaxis = ; @data = ( [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [6, 18, 21, 28, 36, 44, 52, 67, 78, 89], [1, 15, 22, 31, 45, 7, 19, 21, 36, 41], [8, 91, 78, 88, 87, 80, 96, 95, 99, 99] ); @userlist2 = ""; $name1 = "John"; $name2 = "Jacob"; $name3 = "Jingleheimer"; $space = " "; push (@userlist2, $name1); push (@userlist2, $name2); push (@userlist2, $name3); push (@userlist2, $space); $graph1 = GD::Graph::lines->new(1024, 768); $graph1->set( x_label => 'Date', y_label => '% Closed', title => "$Group", y_max_value => 100, y_tick_number => 10, x_label_skip => 7 ) or die $graph->error; $graph1->set( dclrs => [ qw(black dblue gold dgreen dred d +purple lorange dpink marine cyan dbrown lgray lblue lyellow dyellow l +green lred lpurple pink ) ] ); $graph1->set( line_types => [1, 3] ); $graph1->set_legend(@userlist2); my $gd = $graph1->plot(\@data) or die $graph1->error; open (IMG, ">./$Group.jpg"); binmode IMG; print IMG $gd->png; close IMG;

It creates the graph just fine, with the small problem that it only displays the first two entries for the legend, and doesn't seem to display the third. I can't really figure that part out. :-/

This is the altered code, which only changes in that instead of hardcoding the array directly, we reference three already-declared arrays to draw, and get no linear output when the graph is created.

use GD::Graph::lines; $Group = "Test Group"; @name1 = [6, 18, 21, 28, 36, 44, 52, 67, 78, 89]; @name2 = [1, 15, 22, 31, 45, 7, 19, 21, 36, 41]; @name3 = [8, 91, 78, 88, 87, 80, 96, 95, 99, 99]; @xaxis = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; @data = ( [@xaxis], [@name1], [@name2], [@name3] ); @userlist2 = ""; $name1 = "John"; $name2 = "Jacob"; $name3 = "Jingleheimer"; $space = " "; push (@userlist2, $name1); push (@userlist2, $name2); push (@userlist2, $name3); push (@userlist2, $space); $graph1 = GD::Graph::lines->new(1024, 768); $graph1->set( x_label => 'Date', y_label => '% Closed', title => "$Group", y_max_value => 100, y_tick_number => 10, x_label_skip => 7 ) or die $graph->error; $graph1->set( dclrs => [ qw(black dblue gold dgreen dred d +purple lorange dpink marine cyan dbrown lgray lblue lyellow dyellow l +green lred lpurple pink ) ] ); $graph1->set( line_types => [1, 3] ); $graph1->set_legend(@userlist2); my $gd = $graph1->plot(\@data) or die $graph1->error; open (IMG, ">./$Group.jpg"); binmode IMG; print IMG $gd->png; close IMG;
This leads me to believe I've been doing something wrong in GD::Graph the entire time I've been working with it (and my boss, who taught me, before me). Can anyone who's even remotely more involved than I am give me an idea of what's going wrong there?

In reply to Curious issue with Graphing Arrays by SoaponaRope

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.