Hi!
I'm a total newby to google charts and programming in general and therefore
i need some help.
My goal is to create a graph that presents power (W) on the Y axis and time
on the X axis. I first tried doing this with jpgraph but i didn't quite
succeed with that.
I have a sqlite database which a php script pulls data from and converts it
to the json format.
The php script consists of two different arrays and i want to use the data
from these in the area graph.
<?php // content="text/plain; charset=utf-8"
class MyDB extends SQLite3
{
function __construct()
{
$this->open('/home/pi/Documents/Projects/ArduinoSerialImport/solartracker.db');
}
}
$db = new MyDB();
if(!$db){
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
$sql =<<<EOF
SELECT voltage, current, datestamp FROM stuffToPlot;
EOF;
$voltage = array();
$current = array();
$datestamp = array();
$ret = $db->query($sql);
while ($row = $ret->fetchArray(SQLITE3_ASSOC)){
$voltage[] = $row['voltage'];
$current[] = $row['current'];
$datestamp[] = $row['datestamp'];
}
$unixtimestamp = array();
foreach ($datestamp as $nebulosa){
$unixtimestamp[] = strtotime($nebulosa);
}
$power = array();
foreach ($voltage as $key => $door){
$power[] = $door * $current[$key];
}
echo json_encode($power);
echo json_encode($unixtimestamp);
?>
I've read googles page about this
https://developers.google.com/chart/interactive/docs/php_example but i
can't figure out how to set $power to y-axis and $unixtimestamp to x-axis.
Any ideas of how to approach this?
/J
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-visualization-api/a41c632b-0da6-46fc-9645-a89eaab23e94%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.