2012-08-01 138 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 - 底部边距。

查看关于这些函数的文档,它可能与旋转图有点混淆。