我有一个关于谷歌图表的问题,有一个字符串可以工作,如果我想放两个字符串它没有。我的代码
$results=$stmt->fetchAll(PDO::FETCH_ASSOC);
$table = array();
$table['cols'] = array(
array('label' => 'Escola', 'type' => 'string'),
array('label' => 'Dominios', 'type' => 'string'),
array('label' => 'Total', 'type' => 'number')
);
$rows = array();
foreach($results as $r){
$temp = array();
$temp[] = array('v' => $r['escola']);
$temp[] = array('v' => $r['dominio']);
$temp[] = array('v' => (int) $r['total']);
$rows[] = array('c' => $temp);
}
$table['rows'] = $rows;
$jsonTable = json_encode($table);
echo $jsonTable;
和我的图表
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"], 'language': 'pt'});
google.setOnLoadCallback(drawVisualization);
function drawVisualization() {
var jsonData = null;
var json = $.ajax({
url: "xxxxxx.php", // make this url point to the data file
dataType: "json",
async: false,
success: (
function(data) {
console.log(JSON.stringify(data));
jsonData = JSON.stringify(data);
var data = new google.visualization.DataTable(jsonData);
var options = {
'legend':'center',
'title':'Domínios',
'width':800,
'height':600,
colors: ['#e2431e']
}
var chart= new google.visualization.ColumnChart(document.getElementById('chart_div')).
draw(data, options);
})
}).responseText;
}
google.setOnLoadCallback(drawVisualization);
我每次绘制图表时都会收到错误,但我不知道错误在哪里
任何帮助?