나는 막대 그래프 작성에 도움이되는 JpGraph의이 코드 세트를 가지고 있습니다.require_once 함수
<?php
require_once ('src/jpgraph.php');
require_once ('src/jpgraph_bar.php');
$datay=array(1992,1993,1995,1996,1997,1998,2001);
// Size of graph
$width=400;
$height=500;
// Set the basic parameters of the graph
$graph = new Graph($width,$height);
$graph->SetScale('textlin');
$top = 60;
$bottom = 30;
$left = 80;
$right = 30;
$graph->Set90AndMargin($left,$right,$top,$bottom);
// Nice shadow
$graph->SetShadow();
// Setup labels
$lbl = array("Andrew\nTait","Thomas\nAnderssen","Kevin\nSpacey","Nick\nDavidsson",
"David\nLindquist","Jason\nTait","Lorin\nPersson");
$graph->xaxis->SetTickLabels($lbl);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right','center','right');
// Label align for Y-axis
$graph->yaxis->SetLabelAlign('center','bottom');
// Titles
$graph->title->Set('Number of incidents');
// Create a bar pot
$bplot = new BarPlot($datay);
$bplot->SetFillColor('orange');
$bplot->SetWidth(0.5);
$bplot->SetYMin(1990);
?>
그러나이 코드는 코드 상단에 넣으면 작동합니다. 다른 곳에 넣으면 표시가되지 않습니다. 이 문제를 극복 할 수있는 방법이 있습니까? 예를 들어 특정 위치에 코드를 넣으면 코드가 나타납니다. 또한이 그래프의 값으로 내 데이터베이스의 일부 데이터를 사용할 것입니다.
감사합니다.
당신은 오류 메시지를받을 수 있나요 :
난 그냥 할, 당신은 그래프가 보여주고 싶은 페이지에 다음 자체 파일에 넣고, 그리고 것? –
"JpGraph 오류 : HTTP 헤더가 이미 전송되었습니다. studentcourse.php 파일의 38 행 출력 결과입니다." – user1159340
그 메시지는'header' 호출 전에 뭔가를 울릴 때 발생합니다. 이 코드 앞에 다른 내용을 표시하지 않았는지 확인하십시오 (다른 지점에 넣을 때). –