line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2090
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
2
|
1
|
|
|
1
|
|
33
|
use GD::Graph::bars; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use GD::Graph::hbars; |
4
|
|
|
|
|
|
|
use GD::Graph::Data; |
5
|
|
|
|
|
|
|
require 'save.pl'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
$GD::Graph::Error::Debug = 5; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $data = GD::Graph::Data->new( |
10
|
|
|
|
|
|
|
[ |
11
|
|
|
|
|
|
|
["2004/2/1","2004/2/2","2004/2/3","2004/2/4","2004/2/5","2004/2/6","2004/2/7", "2004/2/8", "2004/2/9"], |
12
|
|
|
|
|
|
|
[ 50000, 120000, 240000, 330000, 190000, 80000, 60000, 150000, 210000], |
13
|
|
|
|
|
|
|
[1033101,2200100,5300300,6400400,3192192,1600600, 900900,3333333,4444444], |
14
|
|
|
|
|
|
|
] |
15
|
|
|
|
|
|
|
) or die GD::Graph::Data->error; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $values = $data->copy(); |
18
|
|
|
|
|
|
|
$values->set_y(1, 7, undef) or warn $data->error; |
19
|
|
|
|
|
|
|
$values->set_y(2, 7, undef) or warn $data->error; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my @names = qw/sample19 sample19-h/; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $path = $ENV{GDGRAPH_SAMPLES_PATH} ? $ENV{GDGRAPH_SAMPLES_PATH} : ''; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
for my $my_graph (GD::Graph::bars->new(600,400), |
26
|
|
|
|
|
|
|
GD::Graph::hbars->new(600,400)) |
27
|
|
|
|
|
|
|
{ |
28
|
|
|
|
|
|
|
my $name = shift @names; |
29
|
|
|
|
|
|
|
print STDERR "Processing $name\n"; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$my_graph->set( |
32
|
|
|
|
|
|
|
x_label => 'Date', |
33
|
|
|
|
|
|
|
y1_label => 'Hits', |
34
|
|
|
|
|
|
|
y2_label => 'Megabytes', |
35
|
|
|
|
|
|
|
title => 'Using two axes with different formats', |
36
|
|
|
|
|
|
|
#y1_max_value => 40, |
37
|
|
|
|
|
|
|
#y2_max_value => 8, |
38
|
|
|
|
|
|
|
y_tick_number => 8, |
39
|
|
|
|
|
|
|
y_label_skip => 2, |
40
|
|
|
|
|
|
|
#y_number_format => '%d', ### <-- this will override y{1,2}_number_format |
41
|
|
|
|
|
|
|
y1_number_format => sub { # from perlfaq5 |
42
|
|
|
|
|
|
|
local $_ = shift; |
43
|
|
|
|
|
|
|
1 while s/^([-+]?\d+)(\d{3})/$1,$2/; |
44
|
|
|
|
|
|
|
$_; |
45
|
|
|
|
|
|
|
}, |
46
|
|
|
|
|
|
|
y2_number_format => sub { my $v = shift; sprintf("%.2f",$v/1024) }, |
47
|
|
|
|
|
|
|
long_ticks => 1, |
48
|
|
|
|
|
|
|
two_axes => 1, |
49
|
|
|
|
|
|
|
legend_placement => 'RT', |
50
|
|
|
|
|
|
|
x_label_position => 1/2, |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
bgclr => 'white', |
53
|
|
|
|
|
|
|
fgclr => 'white', |
54
|
|
|
|
|
|
|
boxclr => 'dblue', |
55
|
|
|
|
|
|
|
accentclr => 'dblue', |
56
|
|
|
|
|
|
|
valuesclr => '#ffff77', |
57
|
|
|
|
|
|
|
dclrs => [qw(lgreen lred)], |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
bar_spacing => 1, |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
logo => "${path}logo." . GD::Graph->export_format, |
62
|
|
|
|
|
|
|
logo_position => 'BR', |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
transparent => 0, |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
l_margin => 10, |
67
|
|
|
|
|
|
|
b_margin => 10, |
68
|
|
|
|
|
|
|
r_margin => 10, |
69
|
|
|
|
|
|
|
t_margin => 10, |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
show_values => 1, |
72
|
|
|
|
|
|
|
values_format => "%4.1f", |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
) or warn $my_graph->error; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
if ($name =~ /-h$/) |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
$my_graph->set(x_labels_vertical => 0, values_vertical => 0); |
79
|
|
|
|
|
|
|
$my_graph->set_legend('bottom axis', 'top axis'); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
else |
82
|
|
|
|
|
|
|
{ |
83
|
|
|
|
|
|
|
$my_graph->set(x_labels_vertical => 1, values_vertical => 1); |
84
|
|
|
|
|
|
|
$my_graph->set_legend('left axis', 'right axis'); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
my $font_spec = "../Dustismo_Sans"; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
$my_graph->set_y_label_font($font_spec, 12); |
90
|
|
|
|
|
|
|
$my_graph->set_x_label_font($font_spec, 12); |
91
|
|
|
|
|
|
|
$my_graph->set_y_axis_font($font_spec, 10); |
92
|
|
|
|
|
|
|
$my_graph->set_x_axis_font($font_spec, 10); |
93
|
|
|
|
|
|
|
$my_graph->set_title_font($font_spec, 18); |
94
|
|
|
|
|
|
|
$my_graph->set_legend_font($font_spec, 8); |
95
|
|
|
|
|
|
|
$my_graph->set_values_font($font_spec, 8); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$my_graph->plot($data) or die $my_graph->error; |
98
|
|
|
|
|
|
|
save_chart($my_graph, $name); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |