From 5b77afdafdc3d0f7fc6b1d5945c39b6730ecfc75 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Wed, 13 Oct 2010 14:12:49 +0200 Subject: Bug 595682: Always generate PNG images for charts a=LpSolit --- reports.cgi | 48 +++++++++++++++--------------------------------- 1 file changed, 15 insertions(+), 33 deletions(-) (limited to 'reports.cgi') diff --git a/reports.cgi b/reports.cgi index b53d9521e..fd84f5330 100755 --- a/reports.cgi +++ b/reports.cgi @@ -18,22 +18,15 @@ # Copyright (C) 1998 Netscape Communications Corporation. All # Rights Reserved. # -# Contributor(s): Harrison Page , -# Terry Weissman , -# Dawn Endico -# Bryce Nesbitt , -# Joe Robins , -# Gervase Markham and Adam Spiers -# Added ability to chart any combination of resolutions/statuses. -# Derive the choice of resolutions/statuses from the -All- data file -# Removed hardcoded order of resolutions/statuses when reading from -# daily stats file, so now works independently of collectstats.pl -# version -# Added image caching by date and datasets -# Myk Melez : -# Implemented form field validation and reorganized code. -# Frédéric Buclin : -# Templatization. +# Contributor(s): Harrison Page +# Terry Weissman +# Dawn Endico +# Bryce Nesbitt +# Joe Robins +# Gervase Markham +# Adam Spiers +# Myk Melez +# Frédéric Buclin use strict; @@ -113,14 +106,12 @@ else { my $datasets = join('', $cgi->param('datasets')); - my $type = chart_image_type(); my $data_file = daily_stats_filename($product); - my $image_file = chart_image_name($data_file, $type, $datasets); + my $image_file = chart_image_name($data_file, $datasets); my $url_image = correct_urlbase() . "$graph_url/$image_file"; if (! -e "$graph_dir/$image_file") { - generate_chart("$dir/$data_file", "$graph_dir/$image_file", $type, - $product, $datasets); + generate_chart("$dir/$data_file", "$graph_dir/$image_file", $product, $datasets); } $vars->{'url_image'} = $url_image; @@ -160,17 +151,8 @@ sub daily_stats_filename { return $prodname; } -sub chart_image_type { - # what chart type should we be generating? - my $testimg = Chart::Lines->new(2,2); - my $type = $testimg->can('gif') ? "gif" : "png"; - - undef $testimg; - return $type; -} - sub chart_image_name { - my ($data_file, $type, $datasets) = @_; + my ($data_file, $datasets) = @_; # This routine generates a filename from the requested fields. The problem # is that we have to check the safety of doing this. We can't just require @@ -190,11 +172,11 @@ sub chart_image_name { # show. Charts should be deleted by collectstats.pl nightly. my $id = join ("_", split (":", $datasets)); - return "${data_file}_${id}.$type"; + return "${data_file}_${id}.png"; } sub generate_chart { - my ($data_file, $image_file, $type, $product, $datasets) = @_; + my ($data_file, $image_file, $product, $datasets) = @_; if (! open FILE, $data_file) { if ($product eq '-All-') { @@ -279,5 +261,5 @@ sub generate_chart { ); $img->set (%settings); - $img->$type($image_file, [ @data{('DATE', @labels)} ]); + $img->png($image_file, [ @data{('DATE', @labels)} ]); } -- cgit v1.2.3-24-g4f1b