sub allGraphs { (my $result_ref, my $y_stats) = @_; #produkte ausgeben und für jedes produkt graph aufrufen foreach my $search (@{$result_ref}){ my $product = $search->get_product(); #init Stacked Chart my $graph = GD::Graph::bars->new(1000, 500); $graph->set( title => $product, ); graph($search, $y_stats, $graph); #print ""; print "

"; } } sub graph { (my $result, my $y_stats, my $graph) = @_; my @data; $data[0] = getWeeks($result); my $count = 1; foreach my $stat (@{$y_stats}){ my @temp = getData($result, $stat); $data[$count] = \@temp; $count++; } my $ref = \@data; my $data = GD::Graph::Data->new($ref); my $values = $data->copy; my @legend = @{$y_stats}; $graph->set_legend(@legend); $graph->set( x_label => 'calendar weeks', x_label_position => 1/2, y_label => 'number of bugs', y_label_position => 1/2, long_ticks => 'true', cumulate => 'true', bar_spacing => 50, show_values => $values, include_zero => 'true', grid_lines => 'true', precision => 0, x_min_val => 0, y_min_value => 0, values_space => -15, valuesclr => 'lgrey', dclrs => [ qw( lgreen lyellow lblue orange lred dyellow green pink red dgreen purple) ], legend_placement => 'R|R', legend_spacing => 8, legend_marker_width => 20, legend_marker_height => 15, text_space => 10, ); $graph->set_x_axis_font(GD::Font->MediumBold); $graph->set_y_axis_font(GD::Font->MediumBold); $graph->set_legend_font(GD::Font->MediumBold); $graph->set_title_font(GD::Font->Large); $graph->set_x_label_font(GD::Font->MediumBold); $graph->set_y_label_font(GD::Font->MediumBold); $graph->set_values_font(GD::Font->Small); #plot Stacked Chart and print graph image my $gd = $graph->plot($data); my $product = $result->get_product(); my $url = ">reportImage/stacked$product.png"; open(IMG, $url) or die $!; binmode IMG; print IMG $gd->png; }