Hi Mahendra, 
getData.php is not returning json in a format acceptable by the data table 
constructor.

You can find the spec in the 
documentation<https://developers.google.com/chart/interactive/docs/reference#DataTable>
!

Its a bit more complex, becasue you have dates in your data, those need to 
look something like this:

"cols":[{"id":"date","label":"Date","type":"date"},{"id":"m0","label":"Value 
M0","type":"number"},{"id":"m1","label":"Value M1","type":"number"}],
"rows":[{"c":[{"v":"Date(2013,9,19)"},{"v":"5000"},{"v":"1405.0000000000011"}]},{"c":[{"v":"Date(2013,9,20)"},{"v":"11000"},{"v":"1535.1"}]},
 
etc...

On Friday, 25 October 2013 21:29:11 UTC+11, Mahendra k g wrote:
>
> 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.

Reply via email to