| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
1
|
|
|
1
|
|
1530
|
use GD::Graph::linespoints; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
require 'save.pl'; |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
print STDERR "Processing sample42\n"; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
my $path = $ENV{GDGRAPH_SAMPLES_PATH} ? $ENV{GDGRAPH_SAMPLES_PATH} : ''; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
@data = read_data_from_csv("${path}sample42.dat") |
|
9
|
|
|
|
|
|
|
or die "Cannot read data from sample42.dat"; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$my_graph = new GD::Graph::linespoints( ); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
$my_graph->set( |
|
14
|
|
|
|
|
|
|
x_label => 'X Label', |
|
15
|
|
|
|
|
|
|
y_label => 'Y label', |
|
16
|
|
|
|
|
|
|
title => 'A Lines and Points Graph, reading a CSV file', |
|
17
|
|
|
|
|
|
|
y_max_value => 80, |
|
18
|
|
|
|
|
|
|
y_tick_number => 6, |
|
19
|
|
|
|
|
|
|
y_label_skip => 2, |
|
20
|
|
|
|
|
|
|
markers => [ 1, 5 ], |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
transparent => 0, |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$my_graph->set_legend( 'data set 1', 'data set 2' ); |
|
26
|
|
|
|
|
|
|
$my_graph->plot(\@data); |
|
27
|
|
|
|
|
|
|
save_chart($my_graph, 'sample42'); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub read_data_from_csv |
|
31
|
|
|
|
|
|
|
{ |
|
32
|
|
|
|
|
|
|
my $fn = shift; |
|
33
|
|
|
|
|
|
|
my @d = (); |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
open(ZZZ, $fn) || return (); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
while () |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
|
|
|
|
|
|
chomp; |
|
40
|
|
|
|
|
|
|
# you might want Text::CSV here |
|
41
|
|
|
|
|
|
|
my @row = split /,/; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
for (my $i = 0; $i <= $#row; $i++) |
|
44
|
|
|
|
|
|
|
{ |
|
45
|
|
|
|
|
|
|
undef $row[$i] if ($row[$i] eq 'undef'); |
|
46
|
|
|
|
|
|
|
push @{$d[$i]}, $row[$i]; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
close (ZZZ); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return @d; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |