2016-11-19 1 views
0

PHP에서 다중 그래프는 jpg 그래프로 나타납니다. 첫 번째와 두 번째 플롯은 왼쪽 축과 동일한 축척, 세 번째 플롯은 다른 축척 또는 값 범위를 가지며 축은 오른쪽에 있습니다. 코드와 :jpgraph의 다중 y 축

$width=700; 
    $height=500; 

// Create the graph and set a scale. 
// These two calls are always required 
$graph = new Graph($width, $height); 

$graph->SetScale("intlin"); // X and Y axis 
$graph->SetY2Scale("lin"); // Y2 axis 
$theme_class=new UniversalTheme; 

$graph->SetTheme($theme_class); 
$graph->img->SetAntiAliasing(false); 
$graph->title->Set('Filled Y-grid'); 
$graph->SetBox(false); 

$graph->xaxis->title->Set("Days"); 
$graph->img->SetAntiAliasing(); 

// Create the first line 
$p1 = new LinePlot($ydata1); 
$graph->Add($p1); 
$p1->SetColor("#0033FF"); 
$p1->SetLegend('Rain'); 

// Create the second line 
$p2 = new LinePlot($ydata2); 
$graph->Add($p2); 
$p2->SetColor("#33FFFF"); 
$p2->SetLegend('Irrigation'); 

// Create the third line 
$p3 = new LinePlot($ydata3); 
$graph->AddY2($p3); 
$p3->SetColor("#000000"); 
$p3->SetLegend('Relative Soil Moisture'); 

$graph->legend->SetFrameWeight(0); 

// Setup a title for the graph 
$graph->title->Set($titolo); 
$nome_img=substr($titolo, 0, -10); 

// Display the graph 
$graph->Stroke("tmp/graph_$nome_img.png"); 

echo "<img src=\"tmp/graph_$nome_img.png\"> "; 

내가 왼쪽으로 만 축이 오른쪽 축이 표시되지 않습니다. 당신은 첨부 immage을 참조하십시오. 약간의 오류가 있습니까? 감사합니다. .

enter image description here

답변

0

난 당신이 그래프의 여백을 설정, 그래서 당신의 규모를 볼 수 있고, 생각합니다. 표시되지 않음 :

$graph->SetMargin(50,50,50,50);