2013-08-23 46 views
0

我想引用谷歌電子表格使用桌面爲我的d3可視化中的數據。我能想到的最好的解決方案就是這樣,但我知道這不是很正確。集成tabletop.js與d3.js?

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

回答

2

數據以數組形式出現(請參見下面的輸出);所以不需要申請d3.json。您可以立即開始使用陣列進行d3可視化。

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