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">
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));