mantis1.2.0rc2的图形报表
1、安装JPGRAPH及改程序
(1)、安装:JpGraph PHP5 version Version: 3.0.7,从http://www.aditus.nu/jpgraph/jpdownload.php下载最新版本,记得看清对应的PHP版本。解压缩其中子目录src至mantis\library目录下,改名为jpgraph
(2)、修改文件mantis\library\jpgraph\jpgraph_ttf.inc.php:
elseif( $aFF === FF_SIMSUN ) {
// Do Chinese conversion
if( $this->g2312 == null ) {
include_once 'jpgraph_gb2312.php' ;
$this->g2312 = new GB2312toUTF8();
}
return $this->g2312->gb2utf8($aTxt);
}
改为
elseif( $aFF === FF_SIMSUN ) {
// Do Chinese conversion
return $aTxt;
}
2、后台设置:
(1)安装插件:管理--》管理插件--》安装MantisGraph插件
(2)修改程序:
文件mantis\plugins\MantisGraph\pages\config.php(记得本文件改完后用Ultraedit用ASC-II至UTF-8的转换功能保存为UTF-8格式文件,与总体字符集保持一致):
$t_current_font_selected = array(
'simsun' => false, //增加这一行
'arial' => false,
//--------------------------------------
Sans-serif:<br />
<label><input type="radio" name="font" value="simsun"<?php echo print_font_checked( 'simsun' )?>/>宋体</label><br /> //增加这一行
<label><input type="radio" name="font" value="arial"<?php echo print_font_checked( 'arial' )?>/>Arial</label><br />
//---------------------------------------------------------------------
文件mantis\plugins\MantisGraph\pages\config_edit.php:
if ( plugin_config_get( 'font' ) != $f_font ) {
switch ( $f_font ) {
case 'simsun': //增加这一行
case 'arial':
//----------------------------------------------------------------------
文件mantis\plugins\MantisGraph\core\graph_api.php:
$t_font_map = array(
'simsun' => FF_SIMSUN, //增加这一行
'arial' => FF_ARIAL,
3、设置并启用:
(1)、管理--》管理插件--》点击“MantisGraph 1.0”名字进入设置界面,
(2)、Graph library to use选择“Jpgraph”,Font选择“宋体”
(3)、点击“更改配置”后再看看统计报表中内容,是否已如你所愿。
送上附件是MantisGraph插件的中文化文件,放在mantis\plugins\MantisGraph\lang目录下即可。
不过如果你的界面语言是用简体中文或者繁体中文,那么你会看到图形中的汉字都是乱码,这是因为Mantis对于JPGraph的编码设置不正确造成的,JPGraph会自动将汉字转换为UTF-8编码,但是需要在调用JPGraph的时候对标题等SetFont,Mantis没有做这个操作,因此汉字显示出来都是乱码,解决方法是在Mantis\core\graph_api.php中增加对图形标题等设置字体的代码;
对于柱图和线图,要设置图形标题和x、y轴标题、节点标题:
//Set the title and axis font if the default_language is set to chinese
if (config_get(’default_language’) == ’chinese_simplified’){
$graph->title->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->yaxis->title->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->xaxis->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->yaxis->SetFont(FF_SIMSUN,FS_NORMAL);
}
else if (config_get(’default_language’) == ’chinese_traditional’)
{
$graph->title->SetFont(FF_CHINESE,FS_NORMAL);
$graph->yaxis->title->SetFont(FF_CHINESE,FS_NORMAL);
$graph->xaxis->title->SetFont(FF_CHINESE,FS_NORMAL);
$graph->xaxis->SetFont(FF_CHINESE,FS_NORMAL);
$graph->yaxis->SetFont(FF_CHINESE,FS_NORMAL);
};
对于饼图,要设置图形标题和图例名称:
//Set the title and legend font if the default_language is set to chinese
if (config_get(’default_language’) == ’chinese_simplified’){
$graph->title->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->legend->SetFont(FF_SIMSUN,FS_NORMAL);
}
else if (config_get(’default_language’) == ’chinese_traditional’)
{
$graph->title->SetFont(FF_CHINESE,FS_NORMAL);
$graph->legend->SetFont(FF_CHINESE,FS_NORMAL);
};
大家可以找到位置自己修改,简单的说就是在graph_api.php中每个“$graph->title->Set(…”后面根据当前的图表是柱图、线图还是饼图分别加上上面两段;
实际上,上面两段代码基本上要在每个相关函数中都加入,否则显示出来的图形还是部分有乱码,下面详细写出加入的地方:
第一处:函数graph_bar()中,在“$graph->yaxis->SetFont( $t_graph_font );”和“$p1 = new BarPlot( array_values( $p_metrics ) );”之间加入第一段代码。
第二处:函数graph_group()中,在“$graph->yscale->SetGrace(10);”和“#adds on the same graph”之间依次加入上面两段代码。
第三处:函数graph_group_pct()中,在“$graph->yaxis->scale->ticks->SetDirection(-1);”和“$p1 = new BarPlot($open_bug_count);”之间加入第一段代码。
第四处:函数graph_pie()中,在“$graph->legend->SetFont( $t_graph_font );”和“$p1 = new PiePlot3d( array_values( $p_metrics ) );”之间加入第二段代码。
第五处:函数graph_cumulative_bydate()中,在“$graph->xaxis->SetFont( $t_graph_font );”和“$p1 = new LinePlot($reported_plot, $plot_date);”之间依次加入上面两段代码。
第六处:函数error_check()中,在“$graph->title->SetFont( $t_graph_font, FS_BOLD );”和“$graph->AddText($txt);”之间加入第二段代码。
此时大功告成,所有图形报表都不会出现乱码了。注意其中的“按分类统计”是针对所有项目的,只有选择所有项目后才能正确查看到此报表。
如果版本没有问题,设置没有问题,又仍然没有出现图形报表,建议看看打开报表时的出错信息,此时有可能真是的某个文件有问题,我就遇到了graph_api.php文件里某个变量名不存在的情况,不过,如果是直接下载回来安装的话一般不会出现此问题。
1、安装JPGRAPH及改程序
(1)、安装:JpGraph PHP5 version Version: 3.0.7,从http://www.aditus.nu/jpgraph/jpdownload.php下载最新版本,记得看清对应的PHP版本。解压缩其中子目录src至mantis\library目录下,改名为jpgraph
(2)、修改文件mantis\library\jpgraph\jpgraph_ttf.inc.php:
elseif( $aFF === FF_SIMSUN ) {
// Do Chinese conversion
if( $this->g2312 == null ) {
include_once 'jpgraph_gb2312.php' ;
$this->g2312 = new GB2312toUTF8();
}
return $this->g2312->gb2utf8($aTxt);
}
改为
elseif( $aFF === FF_SIMSUN ) {
// Do Chinese conversion
return $aTxt;
}
2、后台设置:
(1)安装插件:管理--》管理插件--》安装MantisGraph插件
(2)修改程序:
文件mantis\plugins\MantisGraph\pages\config.php(记得本文件改完后用Ultraedit用ASC-II至UTF-8的转换功能保存为UTF-8格式文件,与总体字符集保持一致):
$t_current_font_selected = array(
'simsun' => false, //增加这一行
'arial' => false,
//--------------------------------------
Sans-serif:<br />
<label><input type="radio" name="font" value="simsun"<?php echo print_font_checked( 'simsun' )?>/>宋体</label><br /> //增加这一行
<label><input type="radio" name="font" value="arial"<?php echo print_font_checked( 'arial' )?>/>Arial</label><br />
//---------------------------------------------------------------------
文件mantis\plugins\MantisGraph\pages\config_edit.php:
if ( plugin_config_get( 'font' ) != $f_font ) {
switch ( $f_font ) {
case 'simsun': //增加这一行
case 'arial':
//----------------------------------------------------------------------
文件mantis\plugins\MantisGraph\core\graph_api.php:
$t_font_map = array(
'simsun' => FF_SIMSUN, //增加这一行
'arial' => FF_ARIAL,
3、设置并启用:
(1)、管理--》管理插件--》点击“MantisGraph 1.0”名字进入设置界面,
(2)、Graph library to use选择“Jpgraph”,Font选择“宋体”
(3)、点击“更改配置”后再看看统计报表中内容,是否已如你所愿。
送上附件是MantisGraph插件的中文化文件,放在mantis\plugins\MantisGraph\lang目录下即可。
不过如果你的界面语言是用简体中文或者繁体中文,那么你会看到图形中的汉字都是乱码,这是因为Mantis对于JPGraph的编码设置不正确造成的,JPGraph会自动将汉字转换为UTF-8编码,但是需要在调用JPGraph的时候对标题等SetFont,Mantis没有做这个操作,因此汉字显示出来都是乱码,解决方法是在Mantis\core\graph_api.php中增加对图形标题等设置字体的代码;
对于柱图和线图,要设置图形标题和x、y轴标题、节点标题:
//Set the title and axis font if the default_language is set to chinese
if (config_get(’default_language’) == ’chinese_simplified’){
$graph->title->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->xaxis->title->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->yaxis->title->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->xaxis->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->yaxis->SetFont(FF_SIMSUN,FS_NORMAL);
}
else if (config_get(’default_language’) == ’chinese_traditional’)
{
$graph->title->SetFont(FF_CHINESE,FS_NORMAL);
$graph->yaxis->title->SetFont(FF_CHINESE,FS_NORMAL);
$graph->xaxis->title->SetFont(FF_CHINESE,FS_NORMAL);
$graph->xaxis->SetFont(FF_CHINESE,FS_NORMAL);
$graph->yaxis->SetFont(FF_CHINESE,FS_NORMAL);
};
对于饼图,要设置图形标题和图例名称:
//Set the title and legend font if the default_language is set to chinese
if (config_get(’default_language’) == ’chinese_simplified’){
$graph->title->SetFont(FF_SIMSUN,FS_NORMAL);
$graph->legend->SetFont(FF_SIMSUN,FS_NORMAL);
}
else if (config_get(’default_language’) == ’chinese_traditional’)
{
$graph->title->SetFont(FF_CHINESE,FS_NORMAL);
$graph->legend->SetFont(FF_CHINESE,FS_NORMAL);
};
大家可以找到位置自己修改,简单的说就是在graph_api.php中每个“$graph->title->Set(…”后面根据当前的图表是柱图、线图还是饼图分别加上上面两段;
实际上,上面两段代码基本上要在每个相关函数中都加入,否则显示出来的图形还是部分有乱码,下面详细写出加入的地方:
第一处:函数graph_bar()中,在“$graph->yaxis->SetFont( $t_graph_font );”和“$p1 = new BarPlot( array_values( $p_metrics ) );”之间加入第一段代码。
第二处:函数graph_group()中,在“$graph->yscale->SetGrace(10);”和“#adds on the same graph”之间依次加入上面两段代码。
第三处:函数graph_group_pct()中,在“$graph->yaxis->scale->ticks->SetDirection(-1);”和“$p1 = new BarPlot($open_bug_count);”之间加入第一段代码。
第四处:函数graph_pie()中,在“$graph->legend->SetFont( $t_graph_font );”和“$p1 = new PiePlot3d( array_values( $p_metrics ) );”之间加入第二段代码。
第五处:函数graph_cumulative_bydate()中,在“$graph->xaxis->SetFont( $t_graph_font );”和“$p1 = new LinePlot($reported_plot, $plot_date);”之间依次加入上面两段代码。
第六处:函数error_check()中,在“$graph->title->SetFont( $t_graph_font, FS_BOLD );”和“$graph->AddText($txt);”之间加入第二段代码。
此时大功告成,所有图形报表都不会出现乱码了。注意其中的“按分类统计”是针对所有项目的,只有选择所有项目后才能正确查看到此报表。
如果版本没有问题,设置没有问题,又仍然没有出现图形报表,建议看看打开报表时的出错信息,此时有可能真是的某个文件有问题,我就遇到了graph_api.php文件里某个变量名不存在的情况,不过,如果是直接下载回来安装的话一般不会出现此问题。