I think that this is where I need to make the changes to the above code,
but just not sure how to change
$temp[] = array('v' => (float) $r['Time']);
Any suggestions?
On Tuesday, January 24, 2017 at 1:57:25 PM UTC+11,
[email protected] wrote:
> Hi All,
> I am new to Google charts and this forum.
> For some time now I have been trying to graph temperature against time
> from data I am logging to MySQL, using a variety of different applications
> / java scripts / methods.
> It was not until I first tried Google Charts that I was able to achieve
> any kind of success.
>
> My DB table has 3 columns:-
>
>
> - ID
> - Time
> - Temperature
>
> Starting with a working Pie Chart example, I was able to make the
> necessary changes to create a fully functioning line chart to plot
> temperature against ID, however when I update the code to plot against time
> I get the following error:-
>
> Object doesn't support property or method 'getTimezoneOffset'
>
> Any suggestions as to where in the code below could be causing the
> problem, would be greatly appreciated.
>
> Thanks
> Darren
>
>
> $result = $mysqli->query('SELECT Temperature, Time FROM dp00000001 ORDER
> BY ID DESC LIMIT 2000');
>
> $rows = array();
> $table = array();
> $table['cols'] = array(
>
> array('label' => 'Time', 'type' => 'datetime'),
> array('label' => 'Temperature', 'type' => 'number')
> );
> /* Extract the information from $result */
> foreach($result as $r) {
> $temp = array();
>
> $temp[] = array('v' => (int) $r['Time']);
>
> $temp[] = array('v' => (float) $r['Temperature']);
> $rows[] = array('c' => $temp);
> }
> $table['rows'] = $rows;
>
> $jsonTable = json_encode($table);
> ?>
>
> <html>
> <head>
> <meta http-equiv="refresh" content="600">
> <!--Load the Ajax API-->
> <script type="text/javascript" src="
> https://www.google.com/jsapi"></script>
> <script type="text/javascript" src="
> http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
> <script type="text/javascript">
> // Load the Visualization API and the piechart package.
> google.load('visualization', '1', {'packages':['corechart']});
> // Set a callback to run when the Google Visualization API is loaded.
> google.setOnLoadCallback(drawChart);
> function drawChart() {
> // Create our data table out of JSON data loaded from server.
> var data = new google.visualization.DataTable(<?=$jsonTable?>);
> var options = {
> title: 'Temperature',
> curveType: 'function',
> width: 1200,
> height:400,
> explorer:{maxZoomIn:10,
> actions:["dragToZoom","rightClickToReset"],axis: "horizontal"
> }
> };
> // Instantiate and draw our chart, passing in some options.
> // Do not forget to check your div ID
> var chart = new
> google.visualization.LineChart(document.getElementById('chart_div'));
> chart.draw(data, options);
> }
> </script>
> </head>
> <body>
> <!--this is the div that will hold the pie chart-->
> <div id="chart_div"></div>
> </body>
> </html>
>
--
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/c8640eb4-5019-420f-b42d-aab9055190d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.