0

我有一个谷歌可视化查询,其数据来自融合表,

var query = new google.visualization.Query("https://www.google.com/fusiontables/gvizdata?tq=select * from *******************");

但它只选择前 500 行数据。如何克服这个限制?

4

1 回答 1

1

Fusion Tables SQL 查询已弃用。新版 API 不限于 500 行,详见Fusion Tables API

编辑:

下面是一个使用 Google Fusion Tables 代码 Odi 的仪表板示例,该代码在下面的评论中发布:

function drawTable(response) {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Country Name');
    data.addColumn('number', 'Population in 1960');
    data.addColumn('number', 'Population in 2000');

    var rows = [];
    for (var i = 0; i < response.rows.length; i++) {
        rows.push([response.rows[i][0], parseInt(response.rows[i][1]), parseInt(response.rows[i][2])]); 
    }
    data.addRows(rows);

    var table = new google.visualization.ChartWrapper({
        containerId: 'table_div',
        chartType: 'Table',
        options: {

        }
    });

    var control = new google.visualization.ControlWrapper({
        containerId: 'control_div',
        controlType: 'StringFilter',
        options: {
            filterColumnIndex: 0
        }
    });

    var dashboard = new google.visualization.Dashboard(document.querySelector('#dashboard'));
    dashboard.bind([control], [table]);
    dashboard.draw(data);
}

function getData() {
    // Builds a Fusion Tables SQL query and hands the result to  dataHandler
    var queryUrlHead = 'https://www.googleapis.com/fusiontables/v1/query?sql=';
    var queryUrlTail = '&key=AIzaSyCAI2GoGWfLBvgygLKQp5suUk3RCG7r_ME';
    var tableId = '17jbXdqXSInoNOOm4ZwMKEII0sT_9ukkqt_zuPwU';

    // write your SQL as normal, then encode it
    var query = "SELECT 'Country Name', '1960' as 'Population in 1960', '2000' as 'Population in 2000' FROM " + tableId + " ORDER BY 'Country Name' LIMIT 10";
    var queryurl = encodeURI(queryUrlHead + query + queryUrlTail);

    var jqxhr = $.get(queryurl, drawTable, "jsonp");
}
google.load('visualization', '1', {packages:['controls'], callback: getData});

看到它在这里工作:http: //jsfiddle.net/asgallant/6BXsy/

给出日期格式yyy-mm-dd,这就是你将如何从中创建 Date 对象:

var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
// other columns

var rows = [], dateArray, year, month, day;
for (var i = 0; i < response.rows.length; i++) {
    dateArray = response.rows[i][0].split('-');
    year = parseInt(dateArray[0]);
    month = parseInt(dateArray[1]) - 1;
    day = parseInt(dateArray[2]);
    rows.push([new Date(year, month, day) /*, other data */]); 
}
data.addRows(rows);
于 2013-08-29T14:14:40.637 回答