tags:

views:

91

answers:

1

Hi,

I am creating graphs using GD::Graph::lines. For option set, I have to write fixed values for options e.g. x_label => "label" as per below code:

my $mygraph = GD::Graph::lines->new($x, $y);
$mygraph->set(
    x_label     => 'label1',
    y_label     => 'label2',
    title       => 'title',

    line_types  => [1, 1, 1, 1],
    line_width  => 2,
)

Is there any method to make these options to read variable like $x and $y are input variables?

+1  A: 

Just replace with a variable like this:

my $mygraph = GD::Graph::lines->new($x, $y);
$mygraph->set(
    x_label     => $label_x,
    y_label     => $label_y,
    title       => $title,

    line_types  => [1, 1, 1, 1],
    line_width  => 2,
)
Nifle