mvsjs 0 Newbie Poster

I am using jpgrpah in php to show a bar diagram by using an array as an input. The array is created by a function. I am getting the following error.

Error 25044 - Cannot use auto scaling since it is impossible to determine a valid min/max value for y-axis (only null values)

If I manually give an array instead of using a function it works fine. Need solution for this.

Code - logstat.php

<?php // content="text/plain; charset=utf-8"
require_once ('../../jpgraph/src/jpgraph.php');
require_once ('../../jpgraph/src/jpgraph_bar.php');

if (($handle = fopen("test.csv", "r")) !== FALSE) {
    # Set the parent multidimensional array key to 0.
    while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
        # Count the total keys in the row.
        $c = count($data);

        # Populate the multidimensional array.
        for ($x=0;$x<$c;$x++)
        {
            $csvarray[$x] = $data[$x];
           // echo $data[$x];
        }
    }
    # Close the File.
    fclose($handle);
}
$data[]=explode(",",$data);

//$data=array(55,43,24,12,48,19,33,10,25,15,22,44);
// Create the graph. These two calls are always required
$graph = new Graph(300,200);
$graph->SetScale('textlin');

// Add a drop shadow
$graph->SetShadow();

// Adjust the margin a bit to make more room for titles
$graph->SetMargin(40,30,20,40);

// Create a bar pot
$bplot = new BarPlot($data);

// Adjust fill color
$bplot->SetFillColor('orange');
$graph->Add($bplot);

// Setup the titles
$graph->title->Set('SBI-Log Application status');
$graph->xaxis->title->Set('Hours');
$graph->yaxis->title->Set('No.of Logs applied');

$graph->title->SetFont(FF_FONT1,FS_BOLD);
$graph->yaxis->title->SetFont(FF_FONT1,FS_BOLD);
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

// Display the graph
$graph->Stroke();

?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.