2012-08-01 69 views
0

我已經使用jpgraph創建了一個圖形 - 它可以工作,但是由於我x軸上的標籤長度​​有些文本是'關閉'an不可見。我創建了一個自定義函數來使用換行符,但即使如此,它仍然會剪裁圖表上某個標籤上的幾個字符。在jpgraph(圖表)中更改x軸上標籤的長度

有沒有一種方法來實際定義x軸標籤的實際長度,例如設置一個以像素爲單位的寬度?由於

 // Create the graph. These two calls are always required 
    $graph = new Graph(1000,500,'auto'); 
    $graph->SetScale("textlin"); 

    //$theme_class="DefaultTheme"; 
    //$graph->SetTheme(new $theme_class()); 

    // set major and minor tick positions manually 
    $graph->yaxis->SetTickPositions(array(0,1,2,3,4,5), array(0.5,1.5,2.5,3.5,4.5)); 
    $graph->SetBox(false); 

    //$graph->ygrid->SetColor('gray'); 
    $graph->ygrid->SetFill(false); 
    $graph->xaxis->SetLabelAngle(90); // 45 degrees angle 
    $graph->xaxis->SetTickLabels($new_labels); 
    $graph->yaxis->HideLine(false); 
    $graph->yaxis->HideTicks(false,false); 

    // Create the bar plots 
    $b1plot = new BarPlot($data); 

    // ...and add it to the graPH 
    $graph->Add($b1plot);   

    $b1plot->SetColor("white"); 
    $b1plot->SetFillGradient("#4B0082","white",GRAD_LEFT_REFLECTION); 
    $b1plot->SetWidth(45); 
    $graph->title->Set("Bar Gradient(Left reflection)"); 

    // Display the graph 
    $graph->Stroke(); 
+0

儘管jpgraph是基於php的,但這不是PHP的問題。因爲這個,我刪除了PHP標籤。 – Matt 2012-08-01 15:54:11

回答

0

想通了(幾乎) 萬一別人需要幫助時使用以下命令:

$graph->xaxis->SetLabelAlign('right','center','right'); 
0

我不認爲你可以設置標籤的長度。您需要使用$graph->setMargin(a,b,c,d);$graph->Set90AndMargin(a,b,c,d);來設置圖表的邊距,以獲得旋轉圖。 a - 左邊,b - 右邊,c - 頂部,d - 底部邊距。

查看關於這些函數的文檔,它可能與旋轉圖有點混淆。