[ 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_category.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_category.php,v 1.8.22.1 2007-10-13 22:35:52 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 category, COUNT(category) as count
  40              FROM mantis_bug_table
  41              WHERE project_id='$t_project_id'
  42              GROUP BY category
  43              ORDER BY category";
  44      $result = db_query( $query );
  45      $category_count = db_num_rows( $result );
  46      $total = 0;
  47      $longest_size = 0;
  48      for ($i=0;$i<$category_count;$i++) {
  49          $row = db_fetch_array( $result );
  50          extract( $row );
  51  
  52          $total += $count;
  53          $data_category_arr[] = $category;
  54          $data_count_arr[] = $count;
  55  
  56          if ( strlen( $category ) > $longest_size ) {
  57              $longest_size = strlen( $category );
  58          }
  59      }
  60      $longest_size++;
  61      for ($i=0;$i<$category_count;$i++) {
  62          #echo $data_count_arr[$i];
  63          $percentage = number_format( $data_count_arr[$i] / $total * 100, 1 );
  64          #echo $percentage;
  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( "Category Distribution Graph: $proj_name" );
  83      $graph->title->SetFont( FF_FONT2, FS_BOLD );
  84  
  85      # Create graph
  86      $p1 = new PiePlot( $data_count_arr );
  87      $p1->SetLegends( $data_category_arr );
  88      $p1->SetSize( 260 );
  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