Troubles with first attempt to use the chart package.

Discussion in 'Perl Misc' started by Tad J McClellan, Oct 22, 2008.

  1. Ted Byers <> wrote:
    > There error message I get is:
    >
    > Can't use string ("18") as an ARRAY ref while "strict refs" in use at
    > C:/Perl/site/lib/Chart/Base.pm line 784.
    >
    > I saw this in the documentation:



    > $obj->png ( "filename", \@data );

    ^^
    ^^
    > $chart1->png("chart1.png",@chart1_data);

    ^
    ^


    One of these things is not like the other,
    one of these things just doesn't belong...


    --
    Tad McClellan
    email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
    Tad J McClellan, Oct 22, 2008
    #1
    1. Advertising

  2. Tad J McClellan

    Ted Byers Guest

    There error message I get is:

    Can't use string ("18") as an ARRAY ref while "strict refs" in use at
    C:/Perl/site/lib/Chart/Base.pm line 784.

    I saw this in the documentation:

    # GIFgraph.pm-style API to produce png formatted charts
    @data = ( \@x_tick_labels, \@dataset1, ... , \@dataset_n );
    $obj->png ( "filename", \@data );

    So here are parts of my code:

    My Arrays:
    my @weeks;
    my @ni;
    my @fi;
    my @number_remaining;
    my @number_next_week;
    my @totals;
    my @totals_nw;


    All these are numeric vectors, and are properly populated and used in
    creating a PDF file with a table. Imagine them populated with weeks
    as integers, and the rest with floating point numbers.

    I create the array, following the provided example, as:

    my @chart1_data = (\@weeks,\@fi);
    my @chart2_data = (\@weeks,\@ni);
    my @chart3_data = (\@weeks,\@number_remaining,\@number_next_week);
    my @chart4_data = (\@weeks,\@totals,\@totals_nw);

    And then I create the chart as follows:

    my $chart1 = Chart::Lines->new(500,500);
    my $chart2 = Chart::Lines->new(500,500);
    my $chart3 = Chart::Lines->new(500,500);
    my $chart4 = Chart::Lines->new(500,500);

    my %hash = ('title' => 'Estimated Proportion of captures that may
    produce a refund.',
    'xy_plot' => 'true','precision' => 2,'include_zero' =>
    'true','imagemap' => 'true');
    $chart1->set(%hash);
    %hash = ('title' => 'Estimated Number of captures that may produce a
    refund.');
    $chart2->set(%hash);
    %hash = ('title' => 'Estimated Number of Remaining Refunds.');
    $chart3->set(%hash);
    %hash = ('title' => 'Estimated Value of Refunds.');
    $chart4->set(%hash);

    my @labels = ('Total remaining', 'Estimated number of refunds to occur
    next week');
    $chart3->set ('legend_labels' => \@labels);
    @labels = ('Estimated value of total remaining', 'Estimated value of
    refunds to occur next week');
    $chart4->set ('legend_labels' => \@labels);

    $chart1->png("chart1.png",@chart1_data);
    $chart2->png("chart1.png",@chart2_data);
    $chart3->png("chart1.png",@chart3_data);
    $chart4->png("chart1.png",@chart4_data);


    this clearly follows the example provided (or so it appears), so why
    do I get a complaint about the first 'X' value?

    Any assistance would be appreciated.

    Thanks

    Ted
    Ted Byers, Oct 22, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wes Harrison
    Replies:
    2
    Views:
    494
    Wes Harrison
    Jan 12, 2005
  2. robert maas, see http://tinyurl.com/uh3t

    First attempt to use strtoll: What am I doing wrong?

    robert maas, see http://tinyurl.com/uh3t, Feb 12, 2007, in forum: C Programming
    Replies:
    15
    Views:
    2,444
    Dik T. Winter
    Feb 16, 2007
  3. gnewsgroup
    Replies:
    4
    Views:
    2,989
    Kevin Spencer
    Feb 6, 2008
  4. Tarek
    Replies:
    6
    Views:
    305
    Chris Hohmann
    Nov 19, 2004
  5. GMI
    Replies:
    3
    Views:
    482
    Tad McClellan
    Jun 19, 2005
Loading...

Share This Page