what is problem? i want to add the foreach in google line chart.

40 views
Skip to first unread message

천승만

unread,
Jul 31, 2017, 7:55:04 PM7/31/17
to Google Visualization API
i want to add the foreach in google line chart.

i will describe the data from aws dynamodb.

so, i use unmarshalItem.

but it doesnot work.

i don't know problem.

the result outputs blank in website. maybe 500 error. 
 

source code is as follows:


<html>
<head>
  <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['line']});
      google.charts.setOnLoadCallback(drawChart);

    function drawChart() {
      var data = new google.visualization.DataTable();
      data.addColumn('number', 'id');
      data.addColumn('number', 'data');
      data.addRows([
        [1,100],[2,200],
//      data.addRows([

<?php
        foreach($iterator as $item) {
               $movie = $marshaler->unmarshalItem($item);
               echo "[".$movie['id'].",".$movie['data']."]".",";
         }
?>
        ]);



      var options = {
        chart: {
          title: 'Box Office Earnings in First Two Weeks of Opening',
          subtitle: 'in millions of dollars (USD)'
        },
        width: 900,
        height: 500,
        axes: {
          x: {
            0: {side: 'top'}
          }
        }
      };

      var chart = new google.charts.Line(document.getElementById('line_top_x'));

      chart.draw(data, google.charts.Line.convertOptions(options));

Reply all
Reply to author
Forward
0 new messages