2017-02-14 10 views
2

내가 PHP에 대한의 TeeChart에 안돼서에서 PHP에 대한의 TeeChart를 렌더링합니다.다른 페이지

내가이 생성 된 동일한 PHP 파일에서 차트를 렌더링하는 발견 한 모든 예.

내가 AJAX를 통해 일부 매개 변수를받는 PHP 스크립트를 사용하여 차트를 구축하고, AJAX 호출을 생성 한 페이지의 차트를 렌더링하고 싶습니다.

그럴 수 있습니까? 그것에 관한 어떤 예가 있습니까?

감사합니다.

Jayme Jeffman

여기서 간단한 예

답변

0

:

getchart.php :

<?php 
    // get the q parameter from URL 
$q = $_REQUEST["q"]; 


//Includes 
include "../../sources/TChart.php"; 

$chart1 = new TChart(600,450); 
$chart1->getChart()->getHeader()->setText($q); 
$chart1->getAspect()->setView3D(false); 

$line1 = new Line($chart1->getChart()); 
$line1->setColor(Color::RED()); 
$chart1->addSeries($line1); 

// Speed optimization 
$chart1->getChart()->setAutoRepaint(false); 

for($t = 0; $t <= 10; ++$t) { 
    $line1->addXY($t, (10 + $t), Color::RED()); 
} 

$chart1->getChart()->setAutoRepaint(true); 

$chart1->render("chart1.png");  
$rand=rand(); 
echo "chart1.png?rand=".$rand; 
?> 

인 test.html :

<!DOCTYPE html> 
<html> 
<head> 
<script> 
function showChart(str) { 
    var xmlhttp = new XMLHttpRequest(); 
    xmlhttp.onreadystatechange = function() { 
     if (this.readyState == 4 && this.status == 200) {   
      var image = document.getElementById("get_img"); 
      image.src = xmlhttp.responseText; 
     } 
    } 
    xmlhttp.open("GET", "getchart.php?q="+str, true); 
    xmlhttp.send(); 
} 
</script> 
</head> 
<body> 

<p><b>Enter the chart title below:</b></p> 
<form> 
Chart title: <input type="text" onkeyup="showChart(this.value)"> 
</form> 
<p><img id="get_img" /></p> 
</body> 
</html>