diff options
author | gerv%gerv.net <> | 2003-09-12 07:34:04 +0200 |
---|---|---|
committer | gerv%gerv.net <> | 2003-09-12 07:34:04 +0200 |
commit | 26413f0d9594b465cbee93cadd6c0d355f48a81e (patch) | |
tree | dc8f555a4db5425cfdf49b89bbdbecd0ec42d341 /report.cgi | |
parent | 3be2a68a74e616e971b0002d54642cca1796cf3b (diff) | |
download | bugzilla-26413f0d9594b465cbee93cadd6c0d355f48a81e.tar.gz bugzilla-26413f0d9594b465cbee93cadd6c0d355f48a81e.tar.xz |
Bug 215918 - All graphs that show numeric value on x-axis are useless and misleading. We now sort numerical fields numerically. Patch by gerv; r=jouni, a=justdave.
Diffstat (limited to 'report.cgi')
-rwxr-xr-x | report.cgi | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/report.cgi b/report.cgi index 487859190..970190742 100755 --- a/report.cgi +++ b/report.cgi @@ -156,6 +156,13 @@ my %names; # Read the bug data and count the bugs for each possible value of row, column # and table. +# +# We detect a numerical field, and sort appropriately, if all the values are +# numeric. +my $col_isnumeric = 1; +my $row_isnumeric = 1; +my $tbl_isnumeric = 1; + while (MoreSQLData()) { my ($row, $col, $tbl) = FetchSQLData(); $row = "" if ($row eq $columns{''}); @@ -166,11 +173,35 @@ while (MoreSQLData()) { $names{"col"}{$col}++; $names{"row"}{$row}++; $names{"tbl"}{$tbl}++; + + $col_isnumeric &&= ($col =~ /^-?\d+(\.\d+)?$/o); + $row_isnumeric &&= ($row =~ /^-?\d+(\.\d+)?$/o); + $tbl_isnumeric &&= ($tbl =~ /^-?\d+(\.\d+)?$/o); } -my @col_names = sort(keys(%{$names{"col"}})); -my @row_names = sort(keys(%{$names{"row"}})); -my @tbl_names = sort(keys(%{$names{"tbl"}})); +my @col_names; +my @row_names; +my @tbl_names; +sub numerically { $a <=> $b } + +# Use the appropriate sort for each dimension +if ($col_isnumeric) { + @col_names = sort numerically keys(%{$names{"col"}}); +} else { + @col_names = sort(keys(%{$names{"col"}})); +} + +if ($row_isnumeric) { + @row_names = sort numerically keys(%{$names{"row"}}); +} else { + @row_names = sort(keys(%{$names{"row"}})); +} + +if ($tbl_isnumeric) { + @tbl_names = sort numerically keys(%{$names{"tbl"}}); +} else { + @tbl_names = sort(keys(%{$names{"tbl"}})); +} # The GD::Graph package requires a particular format of data, so once we've # gathered everything into the hashes and made sure we know the size of the |