8) 不過(guò)如果你是用簡(jiǎn)體中文或者繁體中文,那么你會(huì)看到圖形中的漢字都是亂碼,這是因?yàn)镸antis對(duì)于JPGraph的編碼設(shè)置不正確造成的,JPGraph會(huì)自動(dòng)將漢字轉(zhuǎn)換為UTF-8編碼,但是需要在調(diào)用JPGraph的時(shí)候?qū)?biāo)題等SetFont,Mantis沒有做這個(gè)操作,因此漢字顯示出來(lái)都是亂碼,解決方法是在Mantiscoregraph_api.php中增加對(duì)圖形標(biāo)題等設(shè)置字體的代碼; 對(duì)于柱圖和線圖,要設(shè)置圖形標(biāo)題和x、y軸標(biāo)題、節(jié)點(diǎn)標(biāo)題:
//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,F(xiàn)S_NORMAL);
$graph->xaxis->title->SetFont(FF_SIMSUN,F(xiàn)S_NORMAL);
$graph->yaxis->title->SetFont(FF_SIMSUN,F(xiàn)S_NORMAL);
$graph->xaxis->SetFont(FF_SIMSUN,F(xiàn)S_NORMAL);
$graph->yaxis->SetFont(FF_SIMSUN,F(xiàn)S_NORMAL);
}
else if (config_get('default_language') == 'chinese_traditional')
{
$graph->title->SetFont(FF_CHINESE,F(xiàn)S_NORMAL);
$graph->yaxis->title->SetFont(FF_CHINESE,F(xiàn)S_NORMAL) ;
$graph->xaxis->title->SetFont(FF_CHINESE,F(xiàn)S_NORMAL) ;
$graph->xaxis->SetFont(FF_CHINESE,F(xiàn)S_NORMAL);
$graph->yaxis->SetFont(FF_CHINESE,F(xiàn)S_NORMAL); };
對(duì)于餅圖,要設(shè)置圖形標(biāo)題和圖例名稱:
//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,F(xiàn)S_NORMAL);
$graph->legend->SetFont(FF_SIMSUN,F(xiàn)S_NORMAL);
}
else if (config_get('default_language') == 'chinese_traditional')
{
$graph->title->SetFont(FF_CHINESE,F(xiàn)S_NORMAL);
$graph->legend->SetFont(FF_CHINESE,F(xiàn)S_NORMAL);
};
大家可以找到位置自己修改,簡(jiǎn)單的說(shuō)是在graph_api.php中每個(gè)“$graph->title->Set(…”后面根據(jù)當(dāng)前的圖表是柱圖、線圖還是餅圖分別加上上面兩段;
9) 現(xiàn)在你的圖形報(bào)表應(yīng)該可以顯示中文了。 好了,Mantis的配置工作到此結(jié)束了。