2017-02-22 73 views
0

我嘗試在我的頁面上顯示圖像並將其保存到文件中。 我的代碼是:Phplot繪製圖像並將其保存在文件中

//Define the object 
$plot = new PHPlot(400,400,'res.png'); 
$plot->SetIsInline(True); 
//Define some data 
$example_data = array(
array('a',3), 
array('b',5), 
array('c',7), 
array('d',8), 
array('e',2), 
array('f',6), 
array('g',7) 
); 
$plot->SetDataValues($example_data); 
//Turn off X axis ticks and labels because they get in the way: 
$plot->SetXTickLabelPos('none'); 
$plot->SetXTickPos('none'); 
//Draw it 
$plot->DrawGraph(); 

我嘗試調用它的HTML:

<img src="image.php"> 

但olnly救我的圖像輸出中的文件,並在瀏覽器中不顯示它。 我該如何解決這個問題?

回答

0

更改第一行代碼到:

$plot = new PHPlot(400,400); 
0

要保存在服務器上的圖像只需添加這兩條線之前$ plog-> DrawGraph()調用

$plot->SetIsInline(true); 
$plot->SetOutputFile('image.png'); 

然後你可以使用在html中:

<img src="image.png"> 
相關問題