Hallo, ich benötige hilfe bei meinem Google Bar Chart. Ich hole per PHP die 
Daten aus meiner Datenbank mit json, die funktioniert auch einwandfrei, nur 
bekomme ich als Fehlermeldung: a[ec] is not a function. Ich habe dieses 
Beispiel genommen 
https://google-developers.appspot.com/chart/interactive/docs/gallery/columnchart.
 


*Hier einmal meine bar.html:*

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi";
></script>
    <script type="text/javascript" src="//
ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">

      google.load("visualization", "1.1", {packages:["bar"]});

      google.setOnLoadCallback(drawChart);

      function drawChart() {
        var jsonData = $.ajax({
          url: "code.php",
          dataType:"json",
          async: false
          }).responseText;


        var data = new google.visualization.DataTable(jsonData);


        var chart = new google.charts.Bar(document.getElementById(
'columnchart_material'));

        chart.draw(data, {width: 900, height:500} );
      }
    </script>
  </head>
  <body>
    <div id="columnchart_material" style="width: 900px; height: 500px;"
></div>
  </body>
</html>


*Hier meine code.php:*

<?php
    $username = "***";
    $password = "****";
    $host = "localhost";
    $database="***";

    $server = mysql_connect($host, $username, $password);
    $connection = mysql_select_db($database, $server);

    $myquery = "SELECT  `date`, `connectionsEstablished` FROM  `tbl`";
    $query = mysql_query($myquery);

    if ( ! $query ) {
        echo mysql_error();
        die;
    }

    $result = array();


    $table = array();
    $table['cols'] = array(
    array('id' => "", 'label' => 'date', 'pattern' => "", 'type' => 
'datetime'),
    array('id' => "", 'label' => 'connectionsEstablished', 'pattern' => "", 
'type' => 'number')
    );
    $rows = array();
    while ($nt = mysql_fetch_assoc($query))
    {
    $temp = array();
//print_r(date_create($nt['date'])->format("Y, m, d, H, i, s"));
    $temp[] = array('v' => date_create($nt['date'])->format('\n\e\w 
\D\a\t\e\(Y, m, d, H, i, s\)'), 'f' =>NULL);
    $temp[] = array('v' => $nt['connectionsEstablished'], 'f' =>NULL);
    $rows[] = array('c' => $temp);
    }
    $table['rows'] = $rows;
 $jsonTable = json_encode($table, JSON_NUMERIC_CHECK);
echo $jsonTable;

    mysql_close($server);
?>


*Und hier mal ein Ausschnit von dem generierten Jsoncode: *
{"cols":[{"id":"","label":"date","pattern":"","type":"datetime"},{"id":"",
"label":"connectionsEstablished","pattern":"","type":"number"}],"rows":[{"c"
:[{"v":"new
 Date(2014, 11, 06, 09, 48, 
03)","f":null},{"v":23438,"f":null}]},{"c":[{"v":"new Date(2014, 11, 06,
 09, 48, 11)","f":null},{"v":23440,"f":null}]}


Ich hoffe mir kann jemand helfen.

Liebe Grüße Phillip

-- 
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 http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
  • [visualization-api] Googl... Phillip Dörrschuck

Reply via email to