mardi 24 février 2015

JpGraph Error: 25044

I'm keep trying to link my database to jpgraph im using their library and their code to create line graph it works but when I want to add my data its giving me and error called "JpGraph Error: 25044 Cannot use auto scaling since it is impossible to determine a valid min/max value of the Y-axis (only null values)".


I went to their site to know how to link my database but the link was broken so I goggled it and it was all for MySQL and didn't really work with SQLite(using PDO)


This is my code



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

//this is my fourth try so I used this method but still not working
$db = new PDO('sqlite:randvalue.sqlite');
$sth = $db->prepare("SELECT revenue_value FROM company");
$sth->execute();
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll();

$datay1 = array($result); //this is where I link my database to graph

// Setup the graph
$graph = new Graph(300,250);
$graph->SetScale("textlin");

$theme_class=new UniversalTheme;

$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set('Filled Y-grid');
$graph->SetBox(false);

$graph->img->SetAntiAliasing();

$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);

$graph->xgrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xaxis->SetTickLabels(array('A','B','C','D','E','F','G','H','I','J','K','L'));
$graph->xgrid->SetColor('#E3E3E3');

// Create the first line
$p1 = new LinePlot($datay1);
$graph->Add($p1);
$p1->SetColor("#6495ED");
$p1->SetLegend('Line 1');


$graph->legend->SetFrameWeight(1);

// Output line
$graph->Stroke();

?>


I think I'm failing to create an array but I'm just not to sure because it my first time with jpgraph. please help me T_T


Aucun commentaire:

Enregistrer un commentaire