简体   繁体   English

Google图表-GeoChart“数据表不兼容:错误:地址类型未知。”

[英]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.

相关问题 流类型错误:未知类型的属性。 该类型与数组类型不兼容 - Flow Type error: property of unknown type. This type is incompatible with array type Google图表:过滤GeoChart - Google chart : filter GeoChart 谷歌图表:“未捕获(承诺)错误:未知标头类型:4.7278”错误 - Google chart: “Uncaught (in promise) Error: Unknown header type: 4.7278” error 使用 Vue 谷歌图表 - Geochart。 图表在数据更改时重新加载,但图例被删除 - Using Vue Google Chart - Geochart. Chart reloads on data change, but legend gets dropped Google图表错误 - 数据表没有列 - Google Chart Error - Data table has no columns 来自 Google 表格数据的 Google GeoChart 工具提示 - Google GeoChart Tooltips from Google Sheet Data 错误:“barWithErrorBars”不是图表类型。 Vue - chartjs-chart-error-bars - Error: "barWithErrorBars" is not a chart type. Vue - chartjs-chart-error-bars this.each不是Google geochart中的函数错误 - this.each is not a function error in google geochart PhantomJs保存谷歌图表的API GeoChart的png图像 - PhantomJs to save png image of google chart's API GeoChart Google可视化-不兼容的数据表:错误:该表包含的列比预期的要多 - google visualization - Incompatible data table: Error: Table contains more columns than expected
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM