【发布时间】:2020-11-26 02:04:28
【问题描述】:
假设我在 dc.js scatterPlot 中绘制了以下交叉过滤器对象(简化)
var ndx = crossfilter([
{time: 0.5, counts: 8, direction: 1},
{time: 0.8, counts: 0, direction: -1},
{time: 1.0, counts: 8, direction: 1},
{time: 1.2, counts: 1, direction: -1},
{time: 1.8, counts: 10, direction: 1},
{time: 2.0, counts: 2, direction: -1},
{time: 2.2, counts: 14, direction: 1},
{time: 2.5, counts: 0, direction: -1},
...
]);
如何设置交叉过滤器以使输出向量为
x --> [0,1,2,...]
y --> [8,9,14,...] // (average of all "1" direction transition counts, per whole integer time)
我目前所拥有的是来自here
const timeDim = ndx.dimension(d => d.time);
const binwidth = 1;
const timeHist = timeDim
.group(d => {
return binwidth * Math.floor(d / binwidth);
})
.reduceCount(); // I believe this only gives sum, but haven't gotten to averaging yet
当我不关心排除 direction: -1 时,所有尝试都破坏了我的交叉过滤器,例如
const timeSignalDim = ndx.dimension(d => {
if (d.direction === 1) {
return d.time;
}
});
【问题讨论】:
标签: javascript mapreduce dc.js crossfilter