0
我是d3的新手。我試圖每隔10分鐘用立體派想象一些數據。我的json字符串有2個名字(字符串)和活動(雙)的鍵。使用json數據的cubism.js進行可視化
我在定義度量時遇到問題。我看着股票演示,但在調試過程中,我發現控件永遠不會進入d3.json行。我有點卡在這裏。類似地,我想要在選擇.horizon時將名稱傳遞給.data的初始d3.json代碼。
如果我使用正常的隨機數,如在例子中,那麼它的工作原理。
這裏是在隨機功能 -
var foo;
d3.json("rest.php/data", function(data) {
var recs = data.records;
for(var i=0; i<recs.length; i++) {
names[i] = recs[i].name;
foo = random(names[i]);
}
});
d3.select("body").selectAll(".horizon")
.data([foo])
.enter().insert("div")
.attr("class", "horizon")
.call(context.horizon().extent([-20, 20]));
context.on("focus", function(i) {
d3.selectAll(".value").style("right", i == null ? null : context.size() - i + "px");
});
function random(name) {
return context.metric(function(start, stop, step, callback) {
var values = [];
d3.json("rest.php/data", function(rows) {
var recs = rows.records;
start = +start;
start = +stop;
while(start < stop){
start += step;
values.push(recs.activity);
}
callback(null, values);
});
}, name);
}
度量定義當我使用像變種富=隨機(「foo」的)數據的一個定義的字符串;它的工作原理,但是當我嘗試發送像上面的數據失敗並引發錯誤 -
TypeError: metric_ is undefined
var extent = metric_.extent();
我堅持這從2天現在。任何人都可以提供一個提示嗎?
感謝您的幫助。無論如何,我把它整理出來了。 btw ... ur鏈接給出了404 – Dan
抱歉,無法正確格式化鏈接。請立即檢查。 – 2013-07-11 15:55:24
不錯的文章。我還有一個問題。笏你認爲這回合? http://stackoverflow.com/questions/17622138/historical-data-using-cubism – Dan