In these days i'm trying to draw a graph from a file using PhpMyGraph5.0, on the autor's site (http://phpmygraph.abisvmm.nl/) there is this example file:
<?php
//Set content-type header
header("Content-type: image/png");
//Include phpMyGraph5.0.php
include_once('phpMyGraph5.0.php');
//Set config directives
$cfg['title'] = 'Example graph';
$cfg['width'] = 500;
$cfg['height'] = 250;
//Set data
$data = array(
'Jan' => 12,
'Feb' => 25,
'Mar' => 0,
'Apr' => 7,
'May' => 80,
'Jun' => 67,
'Jul' => 45,
'Aug' => 66,
'Sep' => 23,
'Oct' => 23,
'Nov' => 78,
'Dec' => 23
);
//Create phpMyGraph instance
$graph = new phpMyGraph();
//Parse
$graph->parseHorizontalLineGraph($data, $cfg);
?>
Because i need to get the input from a file i've modded the example file changing the $data assignment with:
$data = file("$PATH/$MYFILE");
I've formatted the text inside MYFILE and these are some lines of the file:
'00:00' => 19,
'00:05' => 19,
'00:10' => 21,
...
'17:10' => 21,
'17:15' => 21,
'17:20' => 21,
But when i try to draw the graph i obtain this message instead of the graph:
"exception `Exception` with message `The value of the key %s` is not numeric.`"
I've searched in PhpMyGraph5.0.php and i've found the test that throws the exception:
//Loop
foreach($data as $key => $value) {
//Test
if(!is_numeric($value)) {
throw new Exception('The value of the key "%s" is not numeric.');
}
...
I've tried to substitute the "throw Exception" with this cast:
$value=(int)$value;
but i obtain only an empty graph.
If i manually paste the content of MYFILE inside $data = array(PASTE_HERE); it works, but i can't do it manually.
I think that the problem is about the data type of the value, but i've no ideas on how to solve this problem.
Thanks to everyone and sorry for my bad english.