我在使用某些JavaScript时遇到问题。我正在尝试制作复合dc-js
图表。当我尝试传递变量名时,它会消失在函数中。
var all_functions_array = []; //
banks = ['BANK1','BANK2','BANK3']
for (var i = banks.length - 1; i >= 0; i--) {
var bank = banks[i]
all_functions_array[i] = dateDim.group().reduceSum(function(d) {return d[bank]})
}
// Trying to pass [bank] here in the return but it dosnt work.
我该如何解决?
这是我的数据,csv:
"date","BANK1","BANK2","BANK3","BANK4","BANK5"
1483115384,123,13.7,15,4,6
1483115384,123,13.7,898,5,6
1483114915,132,13.7,415,4,7
1483112683,132,13.8,73,3,7
这就是制作dateDim
的方法:
var url = "tickdata.csv";
d3.csv(csv).then(function(data) {
var ndx = crossfilter(data);
var all = ndx.groupAll();
var dateDim = ndx.dimension(function (d) { return d.date; });