google visualization query limit

天大地大妈咪最大 提交于 2019-12-12 04:36:08

问题


I have a Google visualization query for which data is coming from fusion table as,

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

But it select only first 500 rows of data. How to overcome this limitation?


回答1:


The Fusion Tables SQL queries are deprecated. The new version of the API is not limited to 500 rows, see the Fusion Tables API for details.

Edit:

Here is an example Dashboard using the Google Fusion Tables code Odi posted in comments below:

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});

See it working here: http://jsfiddle.net/asgallant/6BXsy/

Give the date format yyy-mm-dd, this is how you would create Date objects from it:

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);


来源:https://stackoverflow.com/questions/18503647/google-visualization-query-limit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!