Javascript 谷歌图表-地质艺术;不兼容的数据表:错误:未知地址类型。”;
我试图使用从mysql检索并用PHP解析的一组数据生成一个GeoArt。但是,我非常确定错误在于我的JavaScript。我简化了数据,使之更容易理解 以下是我的JavaScript:Javascript 谷歌图表-地质艺术;不兼容的数据表:错误:未知地址类型。”;,javascript,json,google-visualization,Javascript,Json,Google Visualization,我试图使用从mysql检索并用PHP解析的一组数据生成一个GeoArt。但是,我非常确定错误在于我的JavaScript。我简化了数据,使之更容易理解 以下是我的JavaScript: // Load the Visualization API and the piechart package. google.load('visualization', '1.0', {'packages':['geochart']}); // Set a callback to run when the Go
// 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);
}
在页面中,我只看到红色文本,上面写着:
Incompatible data table: Error: Unknown address type.
我有其他图表使用相同格式/布局的datatable工作正常
感谢您的帮助
干杯我修好了。我只需要指定
列
的类型是字符串
或数字
例如:
cols:[
{id:'0',标签:'Country',类型:'string'},
{id:'1',标签:'Downloads',类型:'number'}
],
我把它修好了。我只需要指定列
的类型是字符串
或数字
例如:
cols:[
{id:'0',标签:'Country',类型:'string'},
{id:'1',标签:'Downloads',类型:'number'}
],
如果我将图表类型从GeoChart更改为GeoMap,我只会得到一个不同的错误:“列类型与支持的数据格式不匹配。请参阅支持的格式文档。”
我修复了它,我只需要指定列是字符串还是数字。如果我将图表类型从GeoChart更改为GeoMap,我刚刚收到另一个错误:“列类型与支持的数据格式不匹配。请参阅文档以了解支持的格式。”
我修复了它,我只需要指定列是字符串还是数字。