まずは、絶対動く!MANTIS B級レシピ その7 グラフ表示を參考にgoogle-chartを利用した分析グラフが表示できるようにしておく。

http://d.hatena.ne.jp/mamecyan2001/20090227/1235718883


ソフトウェアの成果物として「バグ曲線」はかかせないものだが、現在のMANTISのグラフはサマリ分析グラフ表示(要約->詳細)の一部にこれがある。
ただし、こいつが2週間以上の分析となるとかなり厳しいグラフになってしまう。本日、小さすぎるのでなんとかしろとの要求を受けた。


以下の設定を変更すればサマリ分析グラフ表示(要約->詳細)で一段表示とか二段表示とか表示Windowの大きさとかが変えられる。
この変更はconfig_inc.phpに$g_graph_window_width(グラフを表示する領域全体の幅)と $g_graph_summary_graphs_per_row
何段で表示するか>を追加記入すれば良い。

以下は全体Windowサイズを800ピクセル,一列に3個グラフを表示指定した例。

# su
# vi /var/www/html/mantis/cpnfig_inc.php

	# what width is used to scale the graphs.
    	$g_graph_window_width = 1000;

        # how many graphs to put in each row in the advanced summary page
        $g_graph_summary_graphs_per_row = 3;

左上の折れ線グラフがバグ曲線


まあ、これでwindowsサイズを大きくして一段表示にすれば解決するようなのだが、あまり大きくしすぎると、Google-chartの関係で棒グラフ表示がNGになってしまうとか、要約で表示されるグラフが出なくなるとか、結果希望する大きさにならない。面倒臭いので、大きな[BUG曲線]をひとつ別に作成することにする。(要約の画面から選択できるグラフをひとつ増やした。)

まああんまり気はすすまないのだがcore/html_api.php中のfunction print_menu_graph()中に新しいグラフのLINK(クリックした時にグラフを表示)を追加する。ひょっとしたら、ユーザ定義でこの関数を上書きできるファイルに記述すればベストなのだろうが・・・わからないので直接修正することとする。

# su
# vi /var/www/html/mantis/core/html_api.php


        # --------------------
        # Print the menu for the graph summary section
        function print_menu_graph() {
                if ( config_get( 'use_jpgraph' ) ) {
                        $t_icon_path = config_get( 'icon_path' );

                        PRINT '<br />';
                        PRINT '<a href="summary_page.php"><img src="' . $t_icon_path.'synthese.gif" border="0" align="center" />' . lang_get( 'synthesis_link' ) . '</a> | ';
                        PRINT '<a href="summary_graph_imp_status.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'status_link' ) . '</a> | ';
                        PRINT '<a href="summary_graph_imp_priority.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'priority_link' ) . '</a> | ';
                        PRINT '<a href="summary_graph_imp_severity.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'severity_link' ) . '</a> | ';
                        PRINT '<a href="summary_graph_imp_category.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'category_link' ) . '</a> | ';
		      //Add start
                        PRINT '<a href="summary_graph_imp_status_sc.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'bug_curve' ) . '</a> | ';                       
                        //Add end
			PRINT '<a href="summary_graph_imp_resolution.php"><img src="' . $t_icon_path.'synthgraph.gif" border="0" align="center" />' . lang_get( 'resolution_link' ) . '</a>';
                }
        }


custom_string.phpに表示文言を追加、私の場合は多国籍軍で使用しているので、使用言語を判別して表示文言(UTF-8)を変えている。

# su
# vi /var/www/html/mantis/custom_string.php

        $s_bug_curve = 'BUG CURVE';
        $wk = lang_get_current();
        switch($wk){
        case 'chinese_traditional':
                $s_bug_curve = '問題結束曲線';
                break;
        case "chinese_simplified":
        break;
        case "japanese":
         $s_bug_curve = 'バグ収束曲線';
        break;
	}

summary_graph_imp_status_sc.phpにグラフを表示するコードを以下のように作成。

<?php
        require_once( 'core.php' );
        $t_core_path = config_get( 'core_path' );
        require_once( $t_core_path.'graph_api.php' );

        access_ensure_project_level( config_get( 'view_summary_threshold' ) );

        html_page_top1();
        html_page_top2();
        print_summary_menu( 'summary_page.php' );
        echo '<br />';

        print_menu_graph();
        $t_graph_width = 1000;

        # gather the data for the graphs
        # gather the data for the graphs
        $t_metrics = create_bug_enum_summary( lang_get( 'status_enum_string' ), 'status' );
        $t_token = token_set( TOKEN_GRAPH, serialize( $t_metrics ) );

?>

<br />
<table class="width100" cellspacing="1">
<tr>
        <td class="form-title">
                <?php echo lang_get( 'graph_imp_status_title' ) ?>
        </td>
</tr>
<tr valign="top">
        <td>
                 <center><img src="summary_graph_cumulative_bydate.php?width=<?php echo $t_graph_width?>" border="0" /></center>
        </td>
</tr>
</table>

<?php html_page_bottom1( __FILE__ ) ?>


以下が表示例です。要約->バグ収束曲線で表示します。

おお!これだと成果物として問題なし!ああ、これもひとえに脱サラ大学生さんのおかげ。再び感謝。