Php 谷歌图表:对象2013-07-25没有方法';获得时间
我正在尝试用GoogleCharts API绘制图表。一列包含日期,另一列包含数字 这是获取我的数据的php页面:Php 谷歌图表:对象2013-07-25没有方法';获得时间,php,mysql,json,google-visualization,Php,Mysql,Json,Google Visualization,我正在尝试用GoogleCharts API绘制图表。一列包含日期,另一列包含数字 这是获取我的数据的php页面: <?php include 'core/init.php'; $result = mysql_query('SELECT amountDone, resultDate FROM result'); $table = array(); $table['cols'] = array( array('label' => 'Done', 'type' => '
<?php
include 'core/init.php';
$result = mysql_query('SELECT amountDone, resultDate FROM result');
$table = array();
$table['cols'] = array(
array('label' => 'Done', 'type' => 'number'),
array('label' => 'Date', 'type' => 'date')
);
$rows = array();
while($r = mysql_fetch_assoc($result)) {
$temp = array();
$temp[] = array('v' => (int)$r['amountDone']);
$temp[] = array('v' => $r['resultDate']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
echo $jsonTable;
?>
在我的主页中,我尝试用以下代码绘制图表:
<script type="text/javascript">
// Load the Visualization API and the piechart package.
google.load('visualization', '1', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "get_json.php",
dataType:"json",
async: false
}).responseText;
// Create our data table out of JSON data loaded from server.
var data = new google.visualization.DataTable(jsonData);
// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, {width: 400, height: 240});
}
</script>
有人知道这意味着什么吗?因为我没有任何其他错误
提前谢谢 将我的查询更改为:
$result = mysql_query("SELECT DATE_FORMAT(resultDate, '%W, %D %M %Y') as Datum, SUM(amountDone) as AmountD, SUM(amountToDo) as AmountT
FROM result
GROUP BY resultDate");
现在类型是string。工作起来很有魅力。:)
Object 2013-07-25 has no method 'getTime
$result = mysql_query("SELECT DATE_FORMAT(resultDate, '%W, %D %M %Y') as Datum, SUM(amountDone) as AmountD, SUM(amountToDo) as AmountT
FROM result
GROUP BY resultDate");