google.load('visualization', '1', { packages: ['linechart', "barchart", "columnchart"] });

var visualization_Demo_PopChange;
var visualization_Demo_UKMigration;
var visualization_Demo_IntMigration;
var visualization_Demo_MigrationChg;
var visualization_Demo_HProjections;
var visualization_Demo_AverageSize;

//test
var visualization_Figure_NumfChart;

function drawAllFigure() 
{
    drawVisualization_Demo_PopChange();
    drawVisualization_Demo_UKMigration();
    drawVisualization_Demo_IntMigration();
    drawVisualization_Demo_MigrationChg();
    drawVisualization_Demo_HProjections();
    drawVisualization_Demo_AverageSize();

    //test
    drawVisualization_Figure_NumfChart();
}

//test-------------------------------------
function drawVisualization_Figure_NumfChart() {
    // To see the data that this visualization uses, browse to
    var query_Figure_NumfChart = new google.visualization.Query(
          'https://spreadsheets.google.com/pub?key=0Am-mi-Fc5ks5dG5Mc2kzQ2I2VnNETFJwQl85VlVzWVE&sheet=test');
    // Send the query with a callback function.
    query_Figure_NumfChart.send(handleQueryResponse_Figure_NumfChart);
}

function handleQueryResponse_Figure_NumfChart(response) {
    if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }

    var data_Fig_NumfChart = response.getDataTable();
    visualization_Fig_NumfChart = new google.visualization.ColumnChart(document.getElementById('div_test'));
    visualization_Fig_NumfChart.draw(data_Fig_NumfChart, { width: 706, height: 300, legend: "bottom", titleY: "test", is3D: true });
}

///--end of test---------------------------------


//Demo_PopChange
function drawVisualization_Demo_PopChange() 
{
    // To see the data that this visualization uses, browse to
    var query_Demo_PopChange= new google.visualization.Query(
          'https://spreadsheets.google.com/pub?key=0Am-mi-Fc5ks5dG5Mc2kzQ2I2VnNETFJwQl85VlVzWVE&sheet=Demo_PopChange');
    // Send the query with a callback function.
    query_Demo_PopChange.send(handleQueryResponse_Demo_PopChange);
}

function handleQueryResponse_Demo_PopChange(response) 
{
    if (response.isError()) 
    {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }
   
    var data_Demo_PopChange = response.getDataTable();
    visualization_Demo_PopChange = new google.visualization.LineChart(document.getElementById('Demo_PopChange'));
    visualization_Demo_PopChange.draw(data_Demo_PopChange, { width: 706, height: 300, legend: "bottom", titleY: "Millions", is3D: true });
}

// Demo_UKMigration
function drawVisualization_Demo_UKMigration() 
{
    // To see the data that this visualization uses, browse to
    var query_Demo_UKMigration = new google.visualization.Query(
          'https://spreadsheets.google.com/pub?key=0Am-mi-Fc5ks5dG5Mc2kzQ2I2VnNETFJwQl85VlVzWVE&sheet=Demo_UKMigration');
    // Send the query with a callback function.
    query_Demo_UKMigration.send(handleQueryResponse_Demo_UKMigration);
}

function handleQueryResponse_Demo_UKMigration(response) {
    if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }

    var data_Demo_UKMigration = response.getDataTable();
    visualization_Demo_UKMigration = new google.visualization.ColumnChart(document.getElementById('Demo_UKMigration'));
    visualization_Demo_UKMigration.draw(data_Demo_UKMigration, { width: 706, height: 300, legend: "bottom", titleY: "Thousands", is3D: true });
}

// Demo_IntMigration
function drawVisualization_Demo_IntMigration() {
    // To see the data that this visualization uses, browse to
    var query_Demo_IntMigration = new google.visualization.Query(
          'https://spreadsheets.google.com/pub?key=0Am-mi-Fc5ks5dG5Mc2kzQ2I2VnNETFJwQl85VlVzWVE&sheet=Demo_IntMigration');
    // Send the query with a callback function.
    query_Demo_IntMigration.send(handleQueryResponse_Demo_IntMigration);
}

function handleQueryResponse_Demo_IntMigration(response) {
    if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }

    var data_Demo_IntMigration = response.getDataTable();
    visualization_Demo_IntMigration = new google.visualization.ColumnChart(document.getElementById('Demo_IntMigration'));
    visualization_Demo_IntMigration.draw(data_Demo_IntMigration, { width: 706, height: 300, legend: "bottom", titleY: "Thousands", is3D: true });
}


// Demo_MigrationChg
function drawVisualization_Demo_MigrationChg() {
    // To see the data that this visualization uses, browse to
    var query_Demo_MigrationChg = new google.visualization.Query(
          'https://spreadsheets.google.com/pub?key=0Am-mi-Fc5ks5dG5Mc2kzQ2I2VnNETFJwQl85VlVzWVE&sheet=Demo_MigrationChg');
    // Send the query with a callback function.
    query_Demo_MigrationChg.send(handleQueryResponse_Demo_MigrationChg);
}

function handleQueryResponse_Demo_MigrationChg(response) {
    if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }

    var data_Demo_MigrationChg = response.getDataTable();
    visualization_Demo_MigrationChg = new google.visualization.ColumnChart(document.getElementById('Demo_MigrationChg'));
    visualization_Demo_MigrationChg.draw(data_Demo_MigrationChg, { width: 706, height: 300, legend: "bottom", titleY: "Thousands", is3D: true });
}


//Demo_HProjections
function drawVisualization_Demo_HProjections() {
    // To see the data that this visualization uses, browse to
    var query_Demo_HProjections = new google.visualization.Query(
          'https://spreadsheets.google.com/pub?key=0Am-mi-Fc5ks5dG5Mc2kzQ2I2VnNETFJwQl85VlVzWVE&sheet=Demo_HProjections');
    // Send the query with a callback function.
    query_Demo_HProjections.send(handleQueryResponse_Demo_HProjections);
}

function handleQueryResponse_Demo_HProjections(response) {
    if (response.isError()) {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }

    var data_Demo_HProjections = response.getDataTable();
    visualization_Demo_HProjections = new google.visualization.LineChart(document.getElementById('Demo_HProjections'));
    visualization_Demo_HProjections.draw(data_Demo_HProjections, { width: 706, height: 300, legend: "bottom", titleY: "Millions", is3D: true });
}


//Demo_AverageSize
function drawVisualization_Demo_AverageSize() 
{
    // To see the data that this visualization uses, browse to
    var query_Demo_AverageSize = new google.visualization.Query(
          'https://spreadsheets.google.com/pub?key=0Am-mi-Fc5ks5dG5Mc2kzQ2I2VnNETFJwQl85VlVzWVE&sheet=Demo_AverageSize');
    // Send the query with a callback function.
    query_Demo_AverageSize.send(handleQueryResponse_Demo_AverageSize);
}

function handleQueryResponse_Demo_AverageSize(response) 
{
    if (response.isError()) 
    {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }
   
    var data_Demo_AverageSize = response.getDataTable();
    visualization_Demo_AverageSize = new google.visualization.LineChart(document.getElementById('Demo_AverageSize'));
    visualization_Demo_AverageSize.draw(data_Demo_AverageSize, { width: 706, height: 300, legend: "bottom", titleY: "Average Size", is3D: true });
}


google.setOnLoadCallback(drawAllFigure);


