2 # This Source Code Form is subject to the terms of the Mozilla Public
3 # License, v. 2.0. If a copy of the MPL was not distributed with this
4 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 package URLTimingGraph
;
8 use GD
::Graph
::linespoints
;
12 use GD
::Graph
::colour
;
17 my $class = ref($proto) || $proto;
19 bless ($self, $class);
20 $self->{data
} = shift || die "No data.";
21 my $args = shift || {};
22 $self->{cgimode
} = $args->{cgimode
} || 0;
23 $self->{title
} = $args->{title
} || "";
24 $self->{types
} = $args->{types
} || ['lines', undef, undef, undef, undef, undef, undef];
25 $self->{dclrs
} = $args->{dclrs
} || [qw(lred)];
26 $self->{legend
} = $args->{legend
} || [qw(undef)];
27 $self->{y_max_value
} = $args->{y_max_value
} || 10000;
28 $self->{width
} = $args->{width
} || 800;
29 $self->{height
} = $args->{height
} || 720;
33 sub _set_standard_options
{
37 y_label
=> 'Page Load Time (msec)',
38 default_type
=> 'points',
39 x_labels_vertical
=> 1,
51 || warn $self->{graph
}->error;
52 $self->{graph
}->set_title_font(GD
::Font
->Giant);
53 $self->{graph
}->set_x_label_font(GD
::Font
->Large);
54 $self->{graph
}->set_y_label_font(GD
::Font
->Large);
55 $self->{graph
}->set_x_axis_font(GD
::Font
->Large);
56 $self->{graph
}->set_y_axis_font(GD
::Font
->Large);
57 $self->{graph
}->set_legend_font(GD
::Font
->Giant);
62 $self->{graph
} = new GD
::Graph
::mixed
($self->{width
},
64 $self->_set_standard_options();
66 $self->{graph
}->set(title
=> $self->{title
},
67 types
=> $self->{types
},
68 y_max_value
=> $self->{y_max_value
},
69 dclrs
=> $self->{dclrs
},
71 || warn $self->{graph
}->error;
73 $self->{graph
}->set_legend( @
{$self->{legend
}} );
75 # draw the graph image
76 $self->{graph
}->plot($self->{data
}) ||
77 die $self->{graph
}->error;
79 # send it back to stdout (or browser)
80 print "Content-type: image/png\n\n" if $self->{cgimode
};
82 print $self->{graph
}->gd->png();