我想使用json变量传递数据。在下面的示例中,json是从外部JSON文件中获取的。我刚接触dc.js,有人能帮助我如何从局部变量传递数据吗?
queue()
.defer(d3.json, "sampledata.json") // sampledata.json is an external json file
.await(makeGraphs);
function makeGraphs() {
//function which proceses the data
}我试过了
var sampledata = [ ....];
queue().defer(d3.json, "sampledata.json") // sampledata.json is an external json file
.await(makeGraphs);
function makeGraphs() {
//function which proceses the data
}但没有起作用。
发布于 2016-10-25 16:53:19
如果你有一个局部变量,那么使用异步调用来传递它是没有意义的。只需将其作为参数直接传递:
var sampleData = [...];//this is your data
makeGraphs(sampleData);//call your function using it as an argument然后:
function makeGraphs(data){//this is the parameter
//use 'data' here
}https://stackoverflow.com/questions/40235162
复制相似问题