3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 use CGI
::Carp
qw(fatalsToBrowser);
11 my $request = new CGI
::Request
;
13 my $id = $request->param('id'); #XXX need to check for valid parameter id
14 my $id2 = $request->param('id2') || undef; # possible comparison test
16 # set up the data for the first graph
17 my $rs = URLTimingDataSet
->new($id);
19 push @data, [ map($_->[1], @
{$rs->{sorted
}}) ]; # URL
20 push @data, [ map($_->[4], @
{$rs->{sorted
}}) ]; # median
21 # '7' is the first slot for individual test run data
22 for (my $idx = 7; $idx < (7+$rs->{count
}); $idx++) {
23 push @data, [ map($_->[$idx], @
{$rs->{sorted
}}) ];
27 # set up the data for the second graph, if requested a second id
28 # need to sort according to the first chart's ordering
31 $rs2 = URLTimingDataSet
->new($id2);
32 my @order = map($_->[0], @
{$rs->{sorted
}}); # get the first chart's order
35 for (@
{$rs2->{sorted
}}) {
42 push @data, [ map($_->[4], @resort) ]; # median
43 for (my $idx = 7; $idx < (7+$rs2->{count
}); $idx++) {
44 push @data, [ map($_->[$idx], @resort) ];
48 # and now convert 'NaN' to undef, if they exist in the data.
49 for (@data) { for (@
$_) { $_ = undef if $_ eq "NaN"; } }
51 # set up the chart parameters
54 $args->{title
} = "id=$id";
56 # need to draw first visit as dotted with points
57 my $types = ['lines','lines']; for (1..$rs->{count
}-1) { push @
$types, undef; }
58 my $dclrs = []; for (0..$rs->{count
}) { push @
$dclrs, 'lred'; }
59 my $legend = [$id]; for (1..$rs->{count
}) { push @
$legend, undef; }
61 push @
$types, 'lines'; for (1..$rs2->{count
}) { push @
$types, undef; }
62 for (0..$rs2->{count
}) { push @
$dclrs, 'lblue'; }
63 push @
$legend, $id2; for (1..$rs2->{count
}) { push @
$legend, undef; }
65 $args->{types
} = $types;
66 $args->{dclrs
} = $dclrs;
67 $args->{legend
} = $legend;
69 #XXX set min to zero, and round max to 1000
70 $args->{y_max_value
} = maxDataOrCap
();
71 ## nope $args->{y_min_value} = 1000;
73 $args->{height
} = 720;
75 my $g = URLTimingGraph
->new(\
@data, $args);
84 if ($rs2 && ($rs->{maximum
} < $rs2->{maximum
})) {
85 $max = $rs2->{maximum
};
87 $max = $rs->{maximum
};
90 #return $max > 10000 ? 10000 : 1000*int($max/1000)+1000;
91 # just return whatever, rounded to 1000
92 return 1000*int($max/1000)+1000;