0
我有一個範圍從(0-1.0)的參數。我正在嘗試創建一個dc.js
條形圖,以便有10條代表(0-0.1)(0.1-0.2)等等。 我使用crossfilter.js
來創建維度和組數據,但它似乎沒有根據需要創建組。使用交叉過濾器創建十進制值組
我嘗試下面的代碼
var fluctuation = ndx.dimension(function (d) {
return d.value;
});
var fluctuationGroup = fluctuation.group(function(d){
return Math.round(d*10)/10;
});
我也嘗試過這樣做的另一種方式。
var fluctuation = ndx.dimension(function (d) {
return Math.round(d.value*10)/10;
});
var fluctuationGroup = fluctuation.group(function(d){
return d;
});
輸出:
每種情況下會發生什麼?儘管我會用Math.floor()來獲得你想要的範圍,而不是Math.round(),但看起來好像都應該或多或少地工作。 –
剛剛編輯帖子,並添加了一張圖片,看起來像 – Andy897
看起來好像可以,不知道您的數據。 fluctuationGroup.all()給你什麼?你期望得到什麼?你的數據是什麼樣的?我建議把它放在jsfiddle或jsbin的工作示例中。 –