1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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 "<img src='reportImage/stacked_$product.png'/>";
print "<img src='reportImage/stacked$product.png'/><br><br>";
}
}
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;
}