0
我正在为我的应用程序(它是一个多语种网站(英文+阿拉伯文))为web和pdf视图制作饼图。 为网络版本我正在使用JQplot js插件来创建饼图的英语和阿拉伯语视图都很好,我正在使用Jpgraph php库。 阿拉伯语视图中的PDF版本问题是传说以相反的顺序来到。传说在阿拉伯文jpgraph逆转
这里是我使用生成饼图对PDF的代码。
function create_graph($chart_array, $plan_id,$lang,$site_lang){
require_once dirname(dirname(dirname(__FILE__))).'/application/third_party/jpgraph/src/jpgraph.php';
require_once dirname(dirname(dirname(__FILE__))).'/application/third_party/jpgraph/src/jpgraph_pie.php';
if(!empty($chart_array)){
foreach($chart_array as $chart){
if ($site_lang=='ar') {
$leg[] = $this->utf8_strrev($chart['0']); // to fix the reverse order issue originally it was only ($leg[] = $chart['0'] - no condition)
}else{
$leg[] = $chart['0'];
}
$data[] = $chart['1'];
}
$flag = true;
foreach($data as $_data){
if($_data != 0)
$flag = false;
}
if(!$flag){
// Create the Pie Graph.
$graph = new PieGraph(1000,950,"auto");
$graph->SetShadow();
$graph ->legend->Pos(0.25,0.8,"right" ,"right");
//$graph->legend->SetFont(FF_VERDANA,FS_BOLD,12);
$graph->title->SetMargin (20);
// Create plots
$size=0.25;
$p1 = new PiePlot($data);
$p1->SetLegends($leg);
$p1->SetSize($size);
$p1->SetGuideLines(true,false);
$p1->SetGuideLinesAdjust(1.8,3);
$p1->SetCenter(0.25,0.32);
//$p1->value->SetFont(FF_VERDANA);
$p1->title->Set($lang->line('initial_investment_data'));
$p1->title->SetMargin(45);
$p1->SetSliceColors(array('red','orange','yellow','green','purple','blue','brown','black'));
$graph->Add($p1);
$graph->Stroke('assets/graph/initial_investment_'.$plan_id.'.png');
}
}
}
修复相反的顺序问题,我已经使用了以下
function utf8_strrev($str){
preg_match_all('/./us', $str, $ar);
return join('', array_reverse($ar[0]));
}
在所有这一切,我得到的是相反的字符串空间(例如:错误变成GUB),所以这个词失去它意思。
我找不到为什么jpgraph正在颠倒传说,以及如何解决这个相反的问题。