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

var visualization_Afford_Mortgage;
var visualization_Afford_MortgageIn;
var visualization_Afford_CouncilTax;
var visualization_Afford_Reposs;
var visualization_Afford_BuyLet;
var visualization_Afford_CouncilRent;
var visualization_Afford_PrivateRent;
var visualization_Afford_HousingBenefitTenure;
var visualization_Afford_HousingBenefitRecip;
var visualization_Afford_RentRebateRecip;
var visualization_Afford_RentAllowanceRecip;

function drawAllFigure() 
{
    drawVisualization_Afford_Mortgage();
    drawVisualization_Afford_MortgageIn();
	drawVisualization_Afford_CouncilTax();
	drawVisualization_Afford_Reposs();
	drawVisualization_Afford_BuyLet();
    drawVisualization_Afford_CouncilRent();
    drawVisualization_Afford_PrivateRent();
    drawVisualization_Afford_HousingBenefitTenure();
    drawVisualization_Afford_HousingBenefitRecip();
    drawVisualization_Afford_RentRebateRecip();
	drawVisualization_Afford_RentAllowanceRecip();
}

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

function handleQueryResponse_Afford_Mortgage(response) 
{
    if (response.isError()) 
    {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }
   
    var data_Afford_Mortgage = response.getDataTable();
    visualization_Afford_Mortgage = new google.visualization.ColumnChart(document.getElementById('Afford_Mortgage'));
    visualization_Afford_Mortgage.draw(data_Afford_Mortgage, { width: 706, height: 300, legend: "bottom", titleY: "Percentage (%)", is3D: true });
}

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

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

    var data_Afford_MortgageIn = response.getDataTable();
    visualization_Afford_MortgageIn = new google.visualization.LineChart(document.getElementById('Afford_MortgageIn'));
    visualization_Afford_MortgageIn.draw(data_Afford_MortgageIn, { width: 706, height: 300, legend: "bottom", titleY: "Ratio: Average Advance / Average Income", is3D: true });
}

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

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

    var data_Afford_CouncilTax = response.getDataTable();
    visualization_Afford_CouncilTax = new google.visualization.ColumnChart(document.getElementById('Afford_CouncilTax'));
    visualization_Afford_CouncilTax.draw(data_Afford_CouncilTax, { width: 706, height: 300, legend: "bottom", titleY: "Percentage (%)", is3D: true, min: "0", isStacked:true });
}


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

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

    var data_Afford_Reposs = response.getDataTable();
    visualization_Afford_Reposs = new google.visualization.LineChart(document.getElementById('Afford_Reposs'));
    visualization_Afford_Reposs.draw(data_Afford_Reposs, { width: 706, height: 300, legend: "bottom", titleY: "No. of cases", is3D: true });
}

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

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

    var data_Afford_BuyLet = response.getDataTable();
    visualization_Afford_BuyLet = new google.visualization.LineChart(document.getElementById('Afford_BuyLet'));
    visualization_Afford_BuyLet.draw(data_Afford_BuyLet, { width: 706, height: 300, legend: "bottom", titleY: "No. of cases / average value", is3D: true });
}

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

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

    var data_Afford_CouncilRent = response.getDataTable();
    visualization_Afford_CouncilRent = new google.visualization.ColumnChart(document.getElementById('Afford_CouncilRent'));
    visualization_Afford_CouncilRent.draw(data_Afford_CouncilRent, { width: 706, height: 300, legend: "bottom", titleY: "Percentage (%)", is3D: true, min: "0", isStacked:true });
}

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

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

    var data_Afford_PrivateRent = response.getDataTable();
    visualization_Afford_PrivateRent = new google.visualization.ColumnChart(document.getElementById('Afford_PrivateRent'));
    visualization_Afford_PrivateRent.draw(data_Afford_PrivateRent, { width: 706, height: 300, legend: "bottom", titleY: "Percentage (%)", is3D: true, min: "0", isStacked:true });
}


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

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

    var data_Afford_HousingBenefitTenure = response.getDataTable();
    visualization_Afford_HousingBenefitTenure = new google.visualization.ColumnChart(document.getElementById('Afford_HousingBenefitTenure'));
    visualization_Afford_HousingBenefitTenure.draw(data_Afford_HousingBenefitTenure, { width: 706, height: 300, legend: "bottom", titleY: "Percentage (%)", is3D: true, min: "0", isStacked:true });
}


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

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

    var data_Afford_HousingBenefitRecip = response.getDataTable();
    visualization_Afford_HousingBenefitRecip = new google.visualization.LineChart(document.getElementById('Afford_HousingBenefitRecip'));
    visualization_Afford_HousingBenefitRecip.draw(data_Afford_HousingBenefitRecip, { width: 706, height: 300, legend: "bottom", titleY: "No. of Housing Benefit Recipients", is3D: true });
}


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

function handleQueryResponse_Afford_RentRebateRecip(response) 
{
    if (response.isError()) 
    {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }
   
    var data_Afford_RentRebateRecip = response.getDataTable();
    visualization_Afford_RentRebateRecip = new google.visualization.LineChart(document.getElementById('Afford_RentRebateRecip'));
    visualization_Afford_RentRebateRecip.draw(data_Afford_RentRebateRecip, { width: 706, height: 300, legend: "bottom", titleY: "No. of Rent Rebate Recipients", is3D: true });
}

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

function handleQueryResponse_Afford_RentAllowanceRecip(response) 
{
    if (response.isError()) 
    {
        alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
        return;
    }
   
    var data_Afford_RentAllowanceRecip = response.getDataTable();
    visualization_Afford_RentAllowanceRecip = new google.visualization.LineChart(document.getElementById('Afford_RentAllowanceRecip'));
    visualization_Afford_RentAllowanceRecip.draw(data_Afford_RentAllowanceRecip, { width: 706, height: 300, legend: "bottom", titleY: "No. of housing benefit rent allowance recipients", is3D: true });
}


google.setOnLoadCallback(drawAllFigure);


