2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is Mozilla page-loader test, released Aug 5, 2001.
17 # The Initial Developer of the Original Code is
18 # Netscape Communications Corporation.
19 # Portions created by the Initial Developer are Copyright (C) 2001
20 # the Initial Developer. All Rights Reserved.
23 # John Morrison <jrgm@netscape.com>, original author
25 # Alternatively, the contents of this file may be used under the terms of
26 # either the GNU General Public License Version 2 or later (the "GPL"), or
27 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 # in which case the provisions of the GPL or the LGPL are applicable instead
29 # of those above. If you wish to allow use of your version of this file only
30 # under the terms of either the GPL or the LGPL, and not to allow others to
31 # use your version of this file under the terms of the MPL, indicate your
32 # decision by deleting the provisions above and replace them with the notice
33 # and other provisions required by the GPL or the LGPL. If you do not delete
34 # the provisions above, a recipient may use your version of this file under
35 # the terms of any one of the MPL, the GPL or the LGPL.
37 # ***** END LICENSE BLOCK *****
38 package URLTimingGraph
;
41 use GD
::Graph
::linespoints
;
42 use GD
::Graph
::points
;
45 use GD
::Graph
::colour
;
50 my $class = ref($proto) || $proto;
52 bless ($self, $class);
53 $self->{data
} = shift || die "No data.";
54 my $args = shift || {};
55 $self->{cgimode
} = $args->{cgimode
} || 0;
56 $self->{title
} = $args->{title
} || "";
57 $self->{types
} = $args->{types
} || ['lines', undef, undef, undef, undef, undef, undef];
58 $self->{dclrs
} = $args->{dclrs
} || [qw(lred)];
59 $self->{legend
} = $args->{legend
} || [qw(undef)];
60 $self->{y_max_value
} = $args->{y_max_value
} || 10000;
61 $self->{width
} = $args->{width
} || 800;
62 $self->{height
} = $args->{height
} || 720;
66 sub _set_standard_options
{
70 y_label
=> 'Page Load Time (msec)',
71 default_type
=> 'points',
72 x_labels_vertical
=> 1,
84 || warn $self->{graph
}->error;
85 $self->{graph
}->set_title_font(GD
::Font
->Giant);
86 $self->{graph
}->set_x_label_font(GD
::Font
->Large);
87 $self->{graph
}->set_y_label_font(GD
::Font
->Large);
88 $self->{graph
}->set_x_axis_font(GD
::Font
->Large);
89 $self->{graph
}->set_y_axis_font(GD
::Font
->Large);
90 $self->{graph
}->set_legend_font(GD
::Font
->Giant);
95 $self->{graph
} = new GD
::Graph
::mixed
($self->{width
},
97 $self->_set_standard_options();
99 $self->{graph
}->set(title
=> $self->{title
},
100 types
=> $self->{types
},
101 y_max_value
=> $self->{y_max_value
},
102 dclrs
=> $self->{dclrs
},
104 || warn $self->{graph
}->error;
106 $self->{graph
}->set_legend( @
{$self->{legend
}} );
108 # draw the graph image
109 $self->{graph
}->plot($self->{data
}) ||
110 die $self->{graph
}->error;
112 # send it back to stdout (or browser)
113 print "Content-type: image/png\n\n" if $self->{cgimode
};
115 print $self->{graph
}->gd->png();