2013-08-07 7 views
1

JpGraph을 사용하여 일부 데이터를 그래프로 나타냅니다. SetScale 함수를 사용하여 y 축 범위를 강제로 지정하면 출력이 시각적으로 그래프 영역을 오버플로합니다. 출력을 그래프 영역으로 잘라 내고 싶습니다.JpGraph SetScale을 사용할 때 LinePlot 출력이 그래프 영역을 초과합니다.

<?php 

require_once ('include/jpgraph/jpgraph.php'); 
require_once ('include/jpgraph/jpgraph_line.php'); 

$datay1 = array(20,7,16,46,90,5,0,5,95); 

// Setup the graph 
$graph = new Graph(400,300); 
$graph->title->Set('Graph Title'); 
$graph->title->font_size = 20; 
$graph->SetScale("textlin",20,50); 

//this version works but does not set the y-axis scale 
//$graph->SetScale("textlin"); 

$p1 = new LinePlot($datay1); 
$graph->Add($p1); 

// Output line 
$graph->Stroke(); 

?> 

이 현재 출력 :
enter image description here

+0

이 문제를 조사한 결과 답변을 찾을 수 없으므로 +1했습니다. 나는 지금도 호기심이 많다. – DrewP84

답변

0

내가 JpGraph 뒤에 회사와 연락을 받았습니다 :
enter image description here

이 (Excel에서 렌더링) 원하는 출력 그들은 도울 수있었습니다. 누락 된 옵션은 다음과 같습니다.

나는 비슷한 문제가있는 다른 사용자에게 도움이되기를 바랍니다.

0
$myMaxY = 50; //You need to set Y Max as you want 

$length = count($datay1); 

for($i = 0; $i < $lenght; $i++) 
{ 
    if($datay1[$i] > $myMaxY) 
     $datay1[$i] = $myMaxY; 
} 

$graph->SetScale("textlin",20,$myMaxY); //Dont forget to change this