[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.7-267-gd69db18
? sunnavy
sunnavy at bestpractical.com
Wed Mar 24 09:00:04 EDT 2010
The branch, 3.8-trunk has been updated
via d69db18defaa3cf6d7506cdae06939b44e7cc677 (commit)
via e326c115973caad67b5164519c13b6c09fbbc9fd (commit)
via d68aecbfee2699af05630be00208c4fd53d7857b (commit)
via c653e1c73fc8a3aab025560b0c8043d016be5886 (commit)
from cb9589931068b4e02b4f0fdb80d5a2a2ecfd2b1b (commit)
Summary of changes:
etc/RT_Config.pm.in | 3 +-
share/fonts/DroidSansFallback.ttf | Bin 0 -> 3022632 bytes
share/html/Search/Chart | 112 +++++++++++++++++++++++--------------
share/html/Search/Elements/Chart | 17 +++++-
4 files changed, 86 insertions(+), 46 deletions(-)
create mode 100755 share/fonts/DroidSansFallback.ttf
- Log -----------------------------------------------------------------
commit c653e1c73fc8a3aab025560b0c8043d016be5886
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Mar 24 20:40:18 2010 +0800
tweak gd graph
diff --git a/share/html/Search/Chart b/share/html/Search/Chart
index 59e9fc6..793c7ad 100644
--- a/share/html/Search/Chart
+++ b/share/html/Search/Chart
@@ -66,52 +66,11 @@ if ($ChartStyle eq 'pie') {
use RT::Report::Tickets;
my $tix = RT::Report::Tickets->new( $session{'CurrentUser'} );
+
my ($count_name, $value_name) = $tix->SetupGroupings(
Query => $Query, GroupBy => $PrimaryGroupBy,
);
-my $chart = $chart_class->new( 600 => 400 );
-
-my $font = RT->Config->Get('ChartFont') || ['verdana', 'arial', gdMediumBoldFont];
-$chart->set_title_font( $font, 12 ) if $chart->can('set_title_font');
-$chart->set_legend_font( $font, 12 ) if $chart->can('set_legend_font');
-$chart->set_x_label_font( $font, 10 ) if $chart->can('set_x_label_font');
-$chart->set_y_label_font( $font, 10 ) if $chart->can('set_y_label_font');
-$chart->set_label_font( $font, 10 ) if $chart->can('set_label_font');
-$chart->set_x_axis_font( $font, 9 ) if $chart->can('set_x_axis_font');
-$chart->set_y_axis_font( $font, 9 ) if $chart->can('set_y_axis_font');
-$chart->set_values_font( $font, 9 ) if $chart->can('set_values_font');
-$chart->set_value_font( $font, 9 ) if $chart->can('set_value_font');
-
-# Pie charts don't like having no input, so we show a special image
-# that indicates an error message. Because this is used in an <img>
-# context, it can't be a simple error message. Without this check,
-# the chart will just be a non-loading image.
-if ($tix->Count == 0) {
- my $plot = GD::Image->new(600 => 400);
- $plot->colorAllocate(255, 255, 255); # background
- my $black = $plot->colorAllocate(0, 0, 0);
-
- require GD::Text::Wrap;
- my $error = GD::Text::Wrap->new($plot,
- color => $black,
- text => loc("No tickets found."),
- );
- $error->set_font( $font, 12 );
- $error->draw(0, 0);
-
- $m->comp( 'SELF:Plot', plot => $plot, %ARGS );
-}
-
-if ($chart_class eq "GD::Graph::bars") {
- $chart->set(
- x_label => $tix->Label( $PrimaryGroupBy ),
- x_labels_vertical => 1,
- y_label => loc('Tickets'),
- show_values => 1
- );
-}
-
my %class = (
Queue => 'RT::Queue',
Owner => 'RT::User',
@@ -121,6 +80,7 @@ my %class = (
my $class = $class{ $PrimaryGroupBy };
my %data;
+my $max_value = 0;
while ( my $entry = $tix->Next ) {
my $key;
if ( $class ) {
@@ -140,6 +100,7 @@ while ( my $entry = $tix->Next ) {
$key = loc($key);
}
$data{ $key } = $value;
+ $max_value = $value if $max_value < $value;
}
# XXX: Convert 1970-01-01 date to the 'Not Set'
@@ -160,6 +121,72 @@ unless (keys %data) {
$data{''} = 0;
}
+
+my $chart = $chart_class->new( 600 => 400 );
+$chart->set( pie_height => 60 ) if $chart_class eq 'GD::Graph::pie';
+my $font = RT->Config->Get('ChartFont');
+$chart->set_title_font( $font, 16 ) if $chart->can('set_title_font');
+$chart->set_legend_font( $font, 16 ) if $chart->can('set_legend_font');
+$chart->set_x_label_font( $font, 14 ) if $chart->can('set_x_label_font');
+$chart->set_y_label_font( $font, 14 ) if $chart->can('set_y_label_font');
+$chart->set_label_font( $font, 14 ) if $chart->can('set_label_font');
+$chart->set_x_axis_font( $font, 12 ) if $chart->can('set_x_axis_font');
+$chart->set_y_axis_font( $font, 12 ) if $chart->can('set_y_axis_font');
+$chart->set_values_font( $font, 12 ) if $chart->can('set_values_font');
+$chart->set_value_font( $font, 12 ) if $chart->can('set_value_font');
+
+# Pie charts don't like having no input, so we show a special image
+# that indicates an error message. Because this is used in an <img>
+# context, it can't be a simple error message. Without this check,
+# the chart will just be a non-loading image.
+if ($tix->Count == 0) {
+ my $plot = GD::Image->new(600 => 400);
+ $plot->colorAllocate(255, 255, 255); # background
+ my $black = $plot->colorAllocate(0, 0, 0);
+
+ require GD::Text::Wrap;
+ my $error = GD::Text::Wrap->new($plot,
+ color => $black,
+ text => loc("No tickets found."),
+ );
+ $error->set_font( $font, 16 );
+ $error->draw(0, 0);
+
+ $m->comp( 'SELF:Plot', plot => $plot, %ARGS );
+}
+
+if ($chart_class eq "GD::Graph::bars") {
+ $chart->set(
+ x_label => $tix->Label( $PrimaryGroupBy ),
+ y_label => loc('Tickets'),
+ show_values => 1,
+ bar_spacing => 5,
+ bargroup_spacing => 10,
+ x_label_position => 0.6,
+ y_label_position => 0.6,
+ values_space => -1,
+# the following line to make sure there's enough space for values to show
+ y_max_value => 5*(int($max_value/5) + 1),
+ );
+}
+
+# refine values' colors, with both Color::Scheme's help and my own tweak
+$chart->{dclrs} = [
+ '66cc66', 'ff6666', 'ffcc66', '663399',
+ '3333cc',
+ '339933', '993333', '996633', '663399',
+ '33cc33', 'cc3333', 'cc9933', '6633cc'
+];
+
+{
+ no warnings 'redefine';
+ *GD::Graph::pick_data_clr = sub {
+ my $self = shift;
+ my $color_hex = $self->{dclrs}[ $_[0] % @{ $self->{dclrs} } - 1 ];
+ return map { hex } ( $color_hex =~ /(..)(..)(..)/ );
+ };
+}
+
my $plot = $chart->plot( [ [sort keys %data], [map $data{$_}, sort keys %data] ] ) or die $chart->error;
$m->comp( 'SELF:Plot', plot => $plot, %ARGS );
</%init>
@@ -170,7 +197,6 @@ $plot => undef
</%ARGS>
<%INIT>
my @types = ('png', 'gif');
-
for my $type (@types) {
$plot->can($type)
or next;
commit d68aecbfee2699af05630be00208c4fd53d7857b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Mar 24 20:53:52 2010 +0800
add share/fonts/DroidSansFallback.ttf
diff --git a/share/fonts/DroidSansFallback.ttf b/share/fonts/DroidSansFallback.ttf
new file mode 100755
index 0000000..38b5b1a
Binary files /dev/null and b/share/fonts/DroidSansFallback.ttf differ
commit e326c115973caad67b5164519c13b6c09fbbc9fd
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Mar 24 20:55:29 2010 +0800
now we have a default beautiful font, plus cjk support too
diff --git a/etc/RT_Config.pm.in b/etc/RT_Config.pm.in
index 9856b79..4a2ab3d 100755
--- a/etc/RT_Config.pm.in
+++ b/etc/RT_Config.pm.in
@@ -1462,8 +1462,7 @@ support for TrueType fonts to use this option.
=cut
-Set($ChartFont, undef);
-
+Set($ChartFont, './share/fonts/DroidSansFallback.ttf');
=item C<@Active_MakeClicky>
commit d69db18defaa3cf6d7506cdae06939b44e7cc677
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Mar 24 20:58:27 2010 +0800
add links to the keys in the table below search graph
diff --git a/share/html/Search/Elements/Chart b/share/html/Search/Elements/Chart
index 3db92c4..d134908 100644
--- a/share/html/Search/Elements/Chart
+++ b/share/html/Search/Elements/Chart
@@ -126,7 +126,22 @@ my $query_string = $m->comp('/Elements/QueryString', %ARGS);
% $total += $value;
<tr class="<%$i%2 ? 'evenline' : 'oddline' %>">
<td class="label collection-as-table">
-<%$key%>
+%# TODO sadly we don't have "creator.city is null" or alike support yet
+%# so no link if the key is undef for now
+% if ( $PrimaryGroupBy !~ /(Daily|Monthly|Annually)$/
+% && $key ne loc('(no value)') ) {
+% my $group = $PrimaryGroupBy; $group =~ s! !.!;
+% my $QueryString = $m->comp('/Elements/QueryString',
+% Query => "$Query and $group = '$key'",
+% Format => $ARGS{Format},
+% RowsPerPage => $ARGS{Rows},
+% OrderBy => $ARGS{OrderBy},
+% Order => $ARGS{Order},
+% );
+<a href=<% RT->Config->Get('WebURL') %>Search/Results.html?<%$QueryString%>><%$key%></a>
+% } else {
+<% $key %>
+% }
</td>
<td class="value collection-as-table">
<%$value%>
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list