user1855009
user1855009

Reputation: 971

Integrating tabletop.js with d3.js?

I want to reference a google spreadsheet using tabletop for for the data in my d3 visualization. The best solution I can come up with is this, but I know that it's not quite right.

window.onload = function() { init() };

var public_spreadsheet_url = 'https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AmYzu_s7QHsmdDNZUzRlYldnWTZCLXdrMXlYQzVxSFE&output=html';

function init() {
  Tabletop.init( { key: public_spreadsheet_url,
                 callback: showInfo,
                 simpleSheet: true } )
}

d3.json("showInfo", function(data) {
  console.log(data);
});

Upvotes: 0

Views: 529

Answers (1)

Isaac
Isaac

Reputation: 2721

The data comes as an array already (see output below); and so there is no need to apply d3.json. You can start using the array for your d3 visualization right away.

window.onload = function() { init() };
var public_spreadsheet_url = "https://docs.google.com/spreadsheet/pub?hl=en_US&hl=en_US&key=0AmYzu_s7QHsmdDNZUzRlYldnWTZCLXdrMXlYQzVxSFE&output=html";
function init() {
    Tabletop.init( { key: public_spreadsheet_url,
        callback: showInfo,
        simpleSheet: true } )
}
function showInfo(rows) {
    console.log(rows);
    // build your d3 vis here..
}

enter image description here

Upvotes: 2

Related Questions