[英]Google Chart - GeoChart “Incompatible data table: Error: Unknown address type.”
I'm trying to generate a GeoChart using a set of data retrieved from mysql and parsed in PHP. 我正在尝试使用从mysql检索并在PHP中解析的一组数据来生成GeoChart。 However, I'm pretty sure that the error lies in my JavaScript.
但是,我非常确定错误在于我的JavaScript。 I've simplified the data to make it easier to understand.
我简化了数据以使其更易于理解。
Here is my JavaScript: 这是我的JavaScript:
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {'packages':['geochart']});
// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the geo chart, passes in the data and
// draws it.
function drawChart() {
// Create the data table.
var data = new google.visualization.DataTable(
{
cols: [
{id: '0', label: 'Country'},
{id: '1', label: 'Downloads'}
],
rows: [
{c:[{v: 'GB'}, {v: 166020}]}
]
}
);
// Set chart options
var options = {
title:'Downloads in Last 30 Days',
width:900,
height:700,
};
// Create and draw the visualization.
visualization = new google.visualization.GeoChart(document.getElementById('chart_div1'));
visualization.draw(data, options);
}
In the page I just get red text that says: 在页面中,我仅收到红色文字,内容为:
Incompatible data table: Error: Unknown address type.
I have other charts working fine using a datatable with the same format/layout. 我还有其他图表可以使用具有相同格式/布局的数据表正常工作。
Any help appreciated, 任何帮助表示赞赏,
Cheers 干杯
I fixed it. 我修好了它。 I just needed to specify the type of
column
was a string
or a number
. 我只需要指定
column
的类型是string
还是number
。
Example: 例:
cols: [
{id: '0', label: 'Country', type: 'string'},
{id: '1', label: 'Downloads', type: 'number'}
],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.