2017-02-22 5 views
0

私はアプリケーションのウェブとpdfビュー(それは多言語サイト(英語+アラビア語)です)の円グラフを作成しています。私はJpgraphのphpライブラリを使用しています。 アラビア語版のpdf版の問題は、伝説が逆順で来ているということです。ここ凡例はアラビア語のjpgraphで逆になる

web view

pdf view

私は、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が凡例を逆にしているのか、この逆の問題を解決する方法が見つかりません。

答えて

1

この問題は解決しました。同僚が私にこれを手伝ってくれました。

これは、Jpgraphではなくphp gdライブラリ、フォントのために凡例のテキストを元に戻すグラフイメージphp Gdライブラリを作成する際の問題です。これは正常に動作します

require_once '/application/third_party/ar-php/I18N/Arabic.php'; 

$Arabic = new I18N_Arabic('Glyphs'); 

$this->Arabic->utf8Glyphs($legend_name); 

:我々は

https://sourceforge.net/projects/ar-php/

You need to do the following: 

1) download library and put that in your project 
2) Include the library file 
3) Create a object of the class 
4) user the object to convert the legend in Arabic with correct font . 

以下のコードを拡張AR-PHPを使用しているこの問題を解決するには 。

関連する問題