私はアプリケーションのウェブとpdfビュー(それは多言語サイト(英語+アラビア語)です)の円グラフを作成しています。私はJpgraphのphpライブラリを使用しています。 アラビア語版のpdf版の問題は、伝説が逆順で来ているということです。ここ凡例はアラビア語のjpgraphで逆になる
私は、PDFのための円グラフを生成するために使用していたコードです。だから言葉がそれを失っ:私は取得していますすべてのスペース(GUBにバグが変化EX)と逆転した文字列である私はこので次
function utf8_strrev($str){
preg_match_all('/./us', $str, $ar);
return join('', array_reverse($ar[0]));
}
を使用していた逆の順序の問題を修正する
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');
}
}
}
意味。
なぜjpgraphが凡例を逆にしているのか、この逆の問題を解決する方法が見つかりません。