gpt4 book ai didi

php - Failed to open error in libchart library in php 无法打开 libchart 库中的错误

转载 作者:搜寻专家 更新时间:2023-10-31 22:04:22 25 4
gpt4 key购买 nike

我在我的项目中使用 Libchart 库来生成图表。我正在尝试在 libchart 中执行示例,但出现以下错误。

imagepng(generated/demo1.png): failed to open stream: No such file or directory in C:\xampp\htdocs\test\fileupload\libchart\classes\view\plot\Plot.php on line 284

这是我的代码

include "libchart/classes/libchart.php";
$chart = new VerticalBarChart(500, 250);
$dataSet = new XYDataSet();
$dataSet->addPoint(new Point("Jan 2005", 273));
$dataSet->addPoint(new Point("Feb 2005", 321));
$dataSet->addPoint(new Point("March 2005", 442));
$dataSet->addPoint(new Point("April 2005", 711));
$chart->setDataSet($dataSet);
$chart->setTitle("Monthly usage for www.example.com");
$chart->render("generated/demo1.png");

当我将最后一行代码更改为 $chart->render(); 时,它会在我的浏览器中打开二进制格式。谁能帮我解决这个错误?

最佳答案

this is my complete code
<?php
include "libchart/classes/libchart.php";

class fileupload
{

var $htmlID_type = "type";
var $type_uploadfile = 0;
var $type_generategraphs = 1;
var $content_html = "";


function __construct()
{
$this->__switch();
$this->__print();
}

function __switch()
{


enter code here
$this->param_type = $this->getParamType();

switch ($this->param_type)
{`enter code here`
case $this->type_uploadfile :
$this->selectFileUplaod ();
break;

case $this->type_generategraphs :
$this->generateGraphs();
break;

}

}

function __print()
{
print <<<HEREDOC

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
body{
margin-left:20%;
margin-right:20%;
margin-top:50px;
}
table, td, th
{
border:1px solid black;
}
th
{
background-color:#00BFFF;
color:white;
}
</style>
</head>
<body>
{$this->content_html}
</body>

</html>



HEREDOC;
}

function getParamType()
{
if (isset ( $_GET [$this->htmlID_type] ))
{
return $_GET [$this->htmlID_type];
}
else
return $this->type_uploadfile;
}



function selectFileUplaod()
{

$con=mysqli_connect("localhost","root","","test");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT
income_id,
month,
paint_cost,
parts_cost,
repair_cost,
excess_Suspense,
sublet,
remove_refit_cost
FROM income");
echo "<h3>Bundamba Income</h3>";
echo "<table>
<tr>
<th>Paint</th>
<th>Parts</th>
<th>Remove Refit Cost</th>
<th>Repair</th>
<th>Excess Suspense</th>
<th>Sublet</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td width=100>" . $row['paint_cost'] . "</td>";
echo "<td width=100>" . $row['parts_cost'] . "</td>";
echo "<td width=100>" . $row['remove_refit_cost'] . "</td>";
echo "<td width=100>" . $row['repair_cost'] . "</td>";
echo "<td width=100>" . $row['excess_Suspense'] . "</td>";
echo "<td width=100>" . $row['sublet'] . "</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
$result1 = mysqli_query($con,"SELECT
cost_of_saleID , paint_liquid ,
paint_consumables,
workshop_consumables,
parts_purchased,
wages_paintshop,
wages_workshop,
suplier_discount,
sublet_cost
FROM cost_of_sale
LIMIT 0 , 30");
echo "<h3>Bundamba cost of sale</h3>";
echo "<table>
<tr>
<th>Paint Consumables</th>
<th>Paint Liquid</th>
<th>Parts Purchased</th>
<th>Workshop Consumables</th>
<th>Wages - Paintshop</th>
<th>Wages - Workshop</th>
<th>Supplier Discounts</th>
<th>Sublets Costs</th>
</tr>";

while($row = mysqli_fetch_array($result1))
{
echo "<tr>";
echo "<td>" . $row['paint_consumables'] . "</td>";
echo "<td>" . $row['paint_liquid'] . "</td>";
echo "<td>" . $row['parts_purchased'] . "</td>";
echo "<td>" . $row['workshop_consumables'] . "</td>";
echo "<td>" . $row['wages_paintshop'] . "</td>";
echo "<td>" . $row['wages_workshop'] . "</td>";
echo "<td>" . $row['suplier_discount'] . "</td>";
echo "<td>" . $row['sublet_cost'] . "</td>";
echo "</tr>";
}
echo "</table>";
$this->content_html = <<<End_Of_String

<FORM action="uploadFile.php?{$this->htmlID_type}={$this->type_generategraphs}" method="POST" />
<input type="submit" value="Income vs Cost" style="margin-top:20px">
<input type="submit" value="Income vs Cost Ratio" style="margin-top:20px">
</FORM>


End_Of_String;


// mysqli_close($con);


}

function generateGraphs()
{
echo getcwd();
print "rrrrr";
header("Content-type:image/png");

$chart = new VerticalBarChart(500, 250);

$dataSet = new XYDataSet();
$dataSet->addPoint(new Point("Jan 2005", 273));
$dataSet->addPoint(new Point("Feb 2005", 321));
$dataSet->addPoint(new Point("March 2005", 442));
$dataSet->addPoint(new Point("April 2005", 711));
$chart->setDataSet($dataSet);
$chart->setTitle("Monthly usage for www.example.com");


$chart->render("demo/generated/demo1.png");
readfile("demo/generated/demo1.png");


// $im = imagecreatefrompng("demo/generated/demo1.png");
// header('Content-Type: image/png');
//imagepng($im);
//imagedestroy($im);

}


}


$obj = new fileupload();
?>

关于php - Failed to open error in libchart library in php 无法打开 libchart 库中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21690552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com