Skip to content

Commit

Permalink
fixed bug #0010694: graph by category broken
Browse files Browse the repository at this point in the history
  - select bug category by id and use bug history referencing
category field in bug_graph_bycategory.
  - fix mapping of category_id in category summary graph

fixed presentation of dates in graph data tables
  - use config variable "date_short_format"

fixed setting of alternate font paths in jpgraph
  - jpgraph will set a constant on first incluse of the class. After
this, the path can't be changed. Moved this setting to the includes.
  • Loading branch information
thraxisp committed Jul 15, 2009
1 parent 03111aa commit f07480d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
14 changes: 9 additions & 5 deletions plugins/MantisGraph/core/graph_api.php
Expand Up @@ -24,6 +24,10 @@


if( OFF == plugin_config_get( 'eczlibrary' ) ) {
$t_font_path = get_font_path();
if( $t_font_path !== '' && !defined('TTF_DIR') ) {
define( 'TTF_DIR', $t_font_path );
}
require_once( 'jpgraph/jpgraph.php' );
require_once( 'jpgraph/jpgraph_line.php' );
require_once( 'jpgraph/jpgraph_bar.php' );
Expand Down Expand Up @@ -71,10 +75,6 @@ function graph_get_font() {
}
return $f;
} else {
$t_font_path = config_get_global( 'system_font_folder' );
if( $t_font_path !== '' ) {
define( 'TTF_DIR', $t_font_path );
}
$t_font_map = array(
'arial' => FF_ARIAL,
'verdana' => FF_VERDANA,
Expand Down Expand Up @@ -759,7 +759,11 @@ function create_category_summary() {
FROM $t_bug_table
WHERE category_id=" . db_param() . " AND $specific_where";
$result2 = db_query_bound( $query, Array( $t_cat_id ) );
$t_metrics[$t_cat_name] = $t_metrics[$t_cat_name] + db_result( $result2, 0, 0 );
if ( isset($t_metrics[$t_cat_name]) ) {
$t_metrics[$t_cat_name] = $t_metrics[$t_cat_name] + db_result( $result2, 0, 0 );
} else {
$t_metrics[$t_cat_name] = db_result( $result2, 0, 0 );
}
}

# end for
Expand Down
13 changes: 7 additions & 6 deletions plugins/MantisGraph/pages/bug_graph_bycategory.php
Expand Up @@ -83,19 +83,19 @@
$t_data[$t_ptr] = array();
foreach ($rows as $t_row) {
// the following function can treat the resolved parameter as an array to match
$t_cat = $t_row['category'];
$t_cat = category_get_name( $t_row->category_id );
if ($t_cat == '')
$t_cat = 'none';
if ( !access_compare_level( $t_row['status'], $t_resolved ) ) {
if ( !access_compare_level( $t_row->status, $t_resolved ) ) {
if (in_array($t_cat, $t_category)) {
$t_data[$t_ptr][$t_cat] ++;
} else {
$t_data[$t_ptr][$t_cat] = 1;
$t_category[] = $t_cat;
}
}
$t_bug[] = $t_row['id'];
$t_bug_cat[$t_row['id']] = $t_cat;
$t_bug[] = $t_row->id;
$t_bug_cat[$t_row->id] = $t_cat;
}

// get the history for these bugs over the interval required to offset the data
Expand Down Expand Up @@ -191,11 +191,12 @@
}
if ( !$t_not_zero ) {
unset( $t_category[ $t ] );
}
}
}
// sort and display the results
sort($t_category);
if ($f_show_as_table) {
$t_date_format = config_get( 'short_date_format' );
html_begin();
html_head_begin();
html_css();
Expand All @@ -209,7 +210,7 @@
}
echo '</tr>';
for ($t_ptr=0; $t_ptr<$t_bin_count; $t_ptr++) {
echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('. $t_marker[$t_ptr] .')'.'</td>';
echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('. date( $t_date_format, $t_marker[$t_ptr] ) .')'.'</td>';
foreach ( $t_category as $t_cat ) {
echo '<td>'.(isset($t_data[$t_ptr][$t_cat]) ? $t_data[$t_ptr][$t_cat] : 0).'</td>';
}
Expand Down
3 changes: 2 additions & 1 deletion plugins/MantisGraph/pages/bug_graph_bystatus.php
Expand Up @@ -158,6 +158,7 @@

// add headers for table
if ($f_show_as_table) {
$t_date_format = config_get( 'short_date_format' );
html_begin();
html_head_begin();
html_css();
Expand Down Expand Up @@ -224,7 +225,7 @@
}
}
if ( $f_show_as_table ) {
echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('. $t_metrics[0][$t_ptr] .')'.'</td>';
echo '<tr class="row-'.($t_ptr%2+1).'"><td>'.$t_ptr.' ('. date( $t_date_format, $t_metrics[0][$t_ptr] ) .')'.'</td>';
for ( $i=1; $i<=$t_label_count; $i++ ) {
echo '<td>'.$t_metrics[$i][$t_ptr].'</td>';
}
Expand Down

0 comments on commit f07480d

Please sign in to comment.