【发布时间】:2020-06-14 06:49:15
【问题描述】:
目前正在尝试创建一个简单的 JPGraph,它从数据库中选择一条数据并将其显示在图表中。
我们遇到了一个错误:
JPGraph 错误 20544 - 无法使用自动缩放,因为它是不可能的 确定 Y 轴的有效最小值/最大值(仅限空值)。
我们真的很难理解这到底意味着什么。
这是我们的 PHP 代码:
<?php
$conn = oci_connect('connection_name', 'Groupassignment2020', 'db_link');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
require_once ('src/jpgraph.php');
require_once ('src/jpgraph_bar.php');
$selectBudget = oci_parse($conn, "SELECT BUDGET FROM REVENUE");
oci_execute($selectBudget);
$data1y=array();
while ($row = oci_fetch_array($selectBudget, OCI_ASSOC+OCI_RETURN_NULLS)) {
$data1y = $row['BUDGET'];
}
$data1y=array($selectBudget,$selectBudget);
// Create the graph. These two calls are always required
$graph = new Graph(1400,800,'auto');
$graph->SetScale("textlin");
// Create the bar plots
$b1plot = new BarPlot($data1y);
$theme_class=new UniversalTheme;
$graph->SetTheme($theme_class);
$graph->yaxis->SetTickPositions(array(0,1000000,205000000), array(0,1000000,205000000));
$graph->SetBox(false);
// Create the grouped bar plot
$gbplot = new GroupBarPlot(array($b1plot));
// ...and add it to the graPH
$graph->Add($gbplot);
$b1plot->SetColor("white");
$b1plot->SetFillColor("#768692");
$graph->title->Set("Bar Plots");
// Display the graph
$graph->Stroke();
?>
所选数据的值为:205000000。
问题可能在于我们如何标记 y 轴刻度位置,但我们并不完全确定。
【问题讨论】: