簡體   English   中英

Google圖表-GeoChart“數據表不兼容:錯誤:地址類型未知。”

[英]Google Chart - GeoChart “Incompatible data table: Error: Unknown address type.”

我正在嘗試使用從mysql檢索並在PHP中解析的一組數據來生成GeoChart。 但是,我非常確定錯誤在於我的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);

}

在頁面中,我僅收到紅色文字,內容為:

Incompatible data table: Error: Unknown address type.

我還有其他圖表可以使用具有相同格式/布局的數據表正常工作。

任何幫助表示贊賞,

干杯

我修好了它。 我只需要指定column的類型是string還是number

例:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM