Hi,
I am facing some problem when i try to get the data from the ajax call i
got the data but in the output it saying no data cloumns. so plz help
my code
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"],
callback:drawChart});
function drawChart() {
var jsonData = $.ajax({
url: "getData.php",
dataType:"json",
async: false
}).responseText;
var options = {
title: 'Your Chart Title'
};
alert(jsonData);//it displaying data here
var data = new google.visualization.DataTable(jsonData);
var chart = new
google.visualization.LineChart(document.getElementById('graph'));
chart.draw(data, options);
}
and this is my php file
<?php
date_default_timezone_set('UTC');
require_once('aws-sdk-for-php/sdk.class.php');
require_once('enterdata.php');
try {
//connecting with the cloud watch
$cw = new AmazonCloudWatch(array('key' => $key, 'secret'
=> $secret));
}
//if there are errors in the secrete and access key
catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
$response = $cw->get_metric_statistics($Namespace, $MetricName,
$start_time, $end_time, $period, $Statistics, $unit, $opts);
$p = array();
$d = array();
$i = 0;
//get the individual parameter and timestamp
foreach
($response->body->GetMetricStatisticsResult->Datapoints->member as $point) {
// Create an array with all results with the timestamp as the key and
the statistic as the valu
$time = date('H:i', strtotime($point->Timestamp));
$d[$i][0] = $time;
$d[$i][1] = (int) $point->Average[0];
$i++;
}
function cmp($a, $b) {
return strtotime($a[0]) - strtotime($b[0]);
}
//sort the data according to the date
usort($d, "cmp");
// Sort by key while maintaining association in order to have an
oldest->newest sorted dataset
$i = 0;
foreach ($d as $p) {
$d[$i][0] = date("d-m", strtotime($d[$i][0]));
$i++;
}
echo json_encode($d);// this php code is working fine
?>
plz help me
--
You received this message because you are subscribed to the Google Groups
"Google Chart 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 http://groups.google.com/group/google-chart-api.
For more options, visit https://groups.google.com/groups/opt_out.