在rowCharts中,顯示的鍵和值僅由組確定。尺寸僅用於過濾,因此切出尺寸不應導致顯示值發生任何變化。您需要讓您的小組跟蹤唯一的採購單,而不是維度。這是一個有點難以正確,高效地做,但我建議你使用Reductio exception aggregation,在這種情況下,它僅僅是一個定義歸謬法減速並在圖表上的值訪問的事情:
reductio()
.exception(function(d) { return d.po; })
.exceptionCount(true)(contractorGroup)
contractorChart
.width(800)
.height(200)
.margins({ top: 20, left: 10, right: 10, bottom: 20 })
.dimension(contractors)
.group(contractorGroup)
.ordinalColors(['#3182bd', '#6baed6', '#9ecae1', '#c6dbef', '#dadaeb'])
.valueAccessor(function(d) { return d.value.exceptionCount; })
.label(function (d) {
return d.key;
})
.title(function (d) {
return d.value;
})
.elasticX(true)
.xAxis().ticks(4);
至於在數據表中,您有正確的想法來創建dc.js常見問題解答中建議的「虛假維度」,但實際上您需要具有合計值的假維度。所以,它的基礎上的一組,而不是:
var uniqueDim = {
bottom: function (num) {
var pos = poDimension.top(Infinity);
// Uses top because the version of Crossfilter being used
// doesn't support group.bottom.
return poGroup.top(num)
.filter(function(d) { return d.value > 0; })
.map(function(d) {
var currPo = pos.filter(function(g) { return g.po === d.key; })[0];
return {
po: d.key,
total: d.value,
contractor: currPo.contractor,
complexity: currPo.complexity
};
});
}
};
工作兩個例子:https://jsfiddle.net/33228p1d/2/
注 - 虛假維度上的過濾被破壞。現在看看:-) –
問題在於group.top返回的組具有在poDimension中不存在相應記錄的0值。需要將組過濾爲具有正值的組用於假維度。 –
工程太棒了!爲什麼我們使用'exceptionCount'來取代價值? – Wesley