如何在JPGraph中设置最小边距?

时间:2014-02-08 00:37:41

标签: php jpgraph

如何在图表上设置最小(或无)边距?

这就是我现在所拥有的:

enter image description here

这就是我想要的结果:

enter image description here

因此结果应该没有边距(或仅限于最小值)。

这是我的代码:

<?php

require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
require_once 'jpgraph/jpgraph_plotline.php';        

$graph = new Graph(600,600);
$graph->SetMargin(40, 10, 10, 0);
$graph->SetScale("textlin");

$theme_class=new UniversalTheme();
$graph->SetTheme($theme_class);

$line = new LinePlot(range(5,25));
$line->SetWeight(1);
$line->SetLegend("test");
$graph->Add($line);

$graph->img->SetAntiAliasing(true);

$graph->title->hide();

$graph->xaxis->Hide();

$graph->xgrid->SetLineStyle("solid");
$graph->xgrid->SetColor('#E3E3E3');

$graph->legend->hide();

$graph->Stroke();

?>

1 个答案:

答案 0 :(得分:0)

更改图表主题有帮助:

$this->graph->graph_theme=null;

这是所有正常工作的代码:

<?php

require_once 'jpgraph/jpgraph.php'; 
require_once 'jpgraph/jpgraph_line.php'; 
require_once 'jpgraph/jpgraph_plotline.php';        

$graph = new Graph(600,600); 
$graph->SetMargin(40, 10, 10, 0); 
$graph->SetScale("textlin");

$this->graph->graph_theme=null;

$line = new LinePlot(range(5,25)); 
$line->SetWeight(1); 
$line->SetLegend("test"); 
$graph->Add($line);

$graph->img->SetAntiAliasing(true);
$graph->title->hide();
$graph->xaxis->Hide();
$graph->xgrid->SetLineStyle("solid"); 
$graph->xgrid->SetColor('#E3E3E3');
$graph->legend->hide();

$graph->Stroke();

?>