I get this error when I execute my PHP code through the localhost. I used jpgraph library to plot. It's connected to my always data database and the error says:
It cannot use auto-scaling since it's impossible to determine a valid min/max value of the Y-axis (only NULL values).
Here is my PHP code
<?php // content="text/plain; charset=utf-8"
require_once('connectDBalwaysdata.inc.php');
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');
$query = "SELECT * FROM `transactions`;";
$result = mysqli_query($link,$query);
$nums = [];
$categories = [];
$num_of_used = array_fill(0,15,0);
while ( $row = mysqli_fetch_assoc($result) ){
$IdCategory = $row['idCategory'];
$query_category = "SELECT category FROM `categories` WHERE idCategory='{$IdCategory}'";
$result_category = mysqli_query($link, $query_category);
$data_category = mysqli_fetch_assoc($result_category);
array_push($categories,$data_category['category']);
$num_of_used[ $row['idCategory']-1 ]++;
array_push($nums,$num_of_used);
}
$graph = new Graph(500,300,'auto');
$graph->SetScale("textlin");
$theme_class = new UniversalTheme;
$graph->SetTheme($theme_class);
$graph->yaxis->SetTickPositions(array(0,10,20,30,40,50,60),array(5,15,25,35,45,55));
$graph->SetBox(false);
$graph->ygrid->SetFill(false);
$graph->xaxis->SetTickLabels($categories);
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
$b1plot = new BarPlot($nums);
$graph->Add($b1plot);
$b1plot->SetColor("white");
$b1plot->SetWidth(45);
$graph->title->Set("Categories of Transactions");
$graph->Stroke();
?>
Same issue happened to me, try this on your call to
SetScale()Obviously you could use different range values but the key for me was defining 0