Google Chart - GeoChart“不兼容的数据表:错误:未知的地址类型”。 [英] Google Chart - GeoChart "Incompatible data table: Error: Unknown address type."

查看:82
本文介绍了Google Chart - GeoChart“不兼容的数据表:错误:未知的地址类型”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用从mysql中检索的一组数据来生成一个GeoChart,并在PHP中进行解析。但是,我敢肯定,错误在于我的JavaScript。我已简化了数据以便于理解。



以下是我的JavaScript:

  //加载可视化API和饼图包。 
google.load('visualization','1.0',{'packages':['geochart']});

//设置回调以在加载Google Visualization API时运行。
google.setOnLoadCallback(drawChart);

//创建和填充数据表的回调,
//实例化地理图表,传入数据并
//绘制数据。

函数drawChart(){

//创建数据表。
var data = new google.visualization.DataTable(
{
cols:[
{id:'0',label:'Country'},
{id :'1',标签:'Downloads'}
],
行:[
{c:[{v:'GB'},{v:166020}]}
]
}
);

//设置图表选项
var options = {
title:'过去30天内的下载',
width:900,
height:700 ,
};

//创建并绘制可视化文件。
visualization = new google.visualization.GeoChart(document.getElementById('chart_div1'));
visualization.draw(data,options);




$ p
$ b

在页面中,我只看到红色文字:

 不兼容的数据表:错误:未知的地址类型。 

我有其他图表可以正常工作,使用具有相同格式/布局的数据表。

b
$ b

任何帮助表示赞赏,

干杯

解决方案我修正了它。我只需要指定列的类型是一个字符串或一个数字

示例:

  cols:[
{id:'0',label:'Country',type:'string'},
{id:'1',label:'Downloads',type:'数字'}
],




I'm trying to generate a GeoChart using a set of data retrieved from mysql and parsed in PHP. However, I'm pretty sure that the error lies in my JavaScript. I've simplified the data to make it easier to understand.

Here is my 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.

Example:

cols: [
  {id: '0', label: 'Country', type: 'string'},
  {id: '1', label: 'Downloads', type: 'number'}
],

这篇关于Google Chart - GeoChart“不兼容的数据表:错误:未知的地址类型”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆