[Rt-commit] r2962 - in rt/branches/QUEBEC-EXPERIMENTAL: . html/Search html/Search/Elements

jesse at bestpractical.com jesse at bestpractical.com
Wed May 25 20:54:10 EDT 2005


Author: jesse
Date: Wed May 25 20:54:09 2005
New Revision: 2962

Added:
   rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Chart
Removed:
   rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Chart.png
Modified:
   rt/branches/QUEBEC-EXPERIMENTAL/   (props changed)
   rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Elements/Chart
Log:
 r17714 at hualien:  jesse | 2005-05-25 20:51:32 -0400
 * Charting component renamed because customer's apache can't serve up .pngs
   through RT
 
 


Added: rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Chart
==============================================================================
--- (empty file)
+++ rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Chart	Wed May 25 20:54:09 2005
@@ -0,0 +1,84 @@
+<%args>
+$Query => "id > 0"
+$PrimaryGroupBy => 'Queue'
+$SecondaryGroupBy => undef
+$ChartStyle => 'bars'
+</%args>
+<%init>
+my @keys;
+my @values;
+my $chart_class; 
+use GD;
+use GD::Text;
+
+if ($ChartStyle eq 'pie') {
+    require GD::Graph::pie;
+    $chart_class= "GD::Graph::pie";
+} else {
+    require GD::Graph::bars;
+    $chart_class= "GD::Graph::bars";
+}
+use RT::Report::Tickets;
+
+my $chart = $chart_class->new( 600 => 400 );
+if ($chart_class eq "GD::Graph::bars") {
+    $chart->set(
+        x_label => $PrimaryGroupBy,
+        x_labels_vertical => 1,
+        y_label => 'Tickets',
+        show_values => 1
+      );
+    $chart->set_legend_font( ['verdana', 'arial', gdMediumBoldFont], 12);
+
+}
+my $tix   = RT::Report::Tickets->new( $session{'CurrentUser'} );
+
+$tix->GroupBy($PrimaryGroupBy);
+$tix->Column( FUNCTION => 'COUNT', FIELD => 'id' );
+$tix->Column( FIELD => $PrimaryGroupBy );
+
+$tix->FromSQL($Query);
+$tix->_DoSearch();
+while ( my $entry = $tix->Next ) {
+    my $class;
+    if ( $PrimaryGroupBy eq 'Queue' ) {
+         $class = "RT::Queue";
+        }
+        elsif ( $PrimaryGroupBy eq 'Owner' ) {
+             $class = "RT::User";
+        }
+        if ($class) {
+            my $q = $class->new( $session{'CurrentUser'} );
+            $q->Load( $entry->__Value($PrimaryGroupBy) );
+            if ($chart_class eq 'GD::Graph::pie') { 
+                 push @keys, $q->Name() . " - ".$entry->id;
+            }
+            else {
+                 push @keys, $q->Name();
+            }
+        }
+        else {
+            if ($chart_class eq 'GD::Graph::pie') { 
+                push @keys, $entry->__Value($PrimaryGroupBy). "- ".$entry->id;
+            }   
+            else {
+                push @keys, $entry->__Value($PrimaryGroupBy);
+                }
+        }
+        push @values, $entry->id;
+    }
+
+      $chart->set( title   => loc("[_1] grouped by [_2]",$Query, $PrimaryGroupBy) 
+      ) or die $chart->error;
+
+
+    unless (@keys && @values) {
+        @keys = ('');
+        @values = (0);
+    }
+
+    my $plot = $chart->plot( [ [@keys], [@values] ] ) or die $chart->error;
+    $r->content_type('image/png');
+    $m->out( $plot->png );
+    $m->abort();
+</%init>

Modified: rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Elements/Chart
==============================================================================
--- rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Elements/Chart	(original)
+++ rt/branches/QUEBEC-EXPERIMENTAL/html/Search/Elements/Chart	Wed May 25 20:54:09 2005
@@ -40,7 +40,7 @@
 my $query_string = $m->comp('/Elements/QueryString', %ARGS);
 </%init>
 
-<img src="<%$RT::WebPath%>/Search/Chart.png?<%$query_string|n%>">
+<img src="<%$RT::WebPath%>/Search/Chart?<%$query_string|n%>">
 <br>
 
 <table class="collection-as-table">


More information about the Rt-commit mailing list