[ Index ]
 

Code source de Mantis 1.1.0rc3

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/graphs/ -> graph_by_severity.php (source)

   1  <?php
   2  # Mantis - a php based bugtracking system
   3  
   4  # Copyright (C) 2000 - 2002  Kenzaburo Ito - kenito@300baud.org
   5  # Copyright (C) 2002 - 2007  Mantis Team   - mantisbt-dev@lists.sourceforge.net
   6  
   7  # Mantis is free software: you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, either version 2 of the License, or
  10  # (at your option) any later version.
  11  #
  12  # Mantis is distributed in the hope that it will be useful,
  13  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15  # GNU General Public License for more details.
  16  #
  17  # You should have received a copy of the GNU General Public License
  18  # along with Mantis.  If not, see <http://www.gnu.org/licenses/>.
  19  
  20      # --------------------------------------------------------
  21      # $Id: graph_by_severity.php,v 1.8.22.1 2007-10-13 22:35:53 giallu Exp $
  22      # --------------------------------------------------------
  23  ?>
  24  <?php
  25      require_once ( '../core.php' );
  26  
  27      $t_core_path = config_get( 'core_path' );
  28  
  29      require_once( $t_core_path.'graph_api.php' );
  30  ?>
  31  <?php
  32      # Grab Data
  33      # ---
  34  
  35      $t_project_id = helper_get_current_project();
  36  
  37      $data_category_arr = array();
  38      $data_count_arr = array();
  39      $query = "SELECT severity, COUNT(severity) as count
  40                  FROM mantis_bug_table
  41                  WHERE status<80 AND
  42                        project_id='$t_project_id'
  43                  GROUP BY severity
  44                  ORDER BY severity";
  45      $result = db_query( $query );
  46      $severity_count = db_num_rows( $result );
  47      $total = 0;
  48      $longest_size = 0;
  49      for ($i=0;$i<$severity_count;$i++) {
  50          $row = db_fetch_array( $result );
  51          extract( $row );
  52  
  53          $total += $count;
  54          $severity = get_enum_element( 'severity', $severity );
  55          $data_category_arr[] = $severity;
  56          $data_count_arr[] = $count;
  57  
  58          if ( strlen( $severity ) > $longest_size ) {
  59              $longest_size = strlen( $severity );
  60          }
  61      }
  62      $longest_size++;
  63      for ($i=0;$i<$severity_count;$i++) {
  64          $percentage = number_format( $data_count_arr[$i] / $total * 100, 1 );
  65          $percentage_str = str_pad($percentage, 5, ' ', STR_PAD_LEFT);
  66          $data_category_arr[$i] = str_pad($data_category_arr[$i], $longest_size);
  67          $data_category_arr[$i] = $data_category_arr[$i].$percentage_str;
  68          if ( $percentage < 1 ) {
  69              $data_count_arr[$i] = 0;
  70          }
  71      }
  72  
  73      $proj_name = project_get_field( $t_project_id, 'name' );
  74  
  75      # Setup Graph
  76      # ---
  77  
  78      $graph = new PieGraph(800,600);
  79      $graph->SetShadow();
  80  
  81      # Set A title for the plot
  82      $graph->title->Set( "SPR Severity Distribution Graph: $proj_name" );
  83      $graph->title->SetFont( FF_FONT1, FS_BOLD );
  84  
  85      # Create graph
  86      $p1 = new PiePlot( $data_count_arr );
  87      $p1->SetLegends( $data_category_arr );
  88      $p1->SetSize( 250 );
  89      $p1->SetCenter( 0.35 );
  90      $p1->SetSliceColors( $g_color_arr );
  91      $p1->SetStartAngle( -90 );
  92  
  93      $graph->Add( $p1 );
  94  
  95      $graph->Stroke();
  96  ?>


Généré le : Thu Nov 29 09:42:17 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics