あなたは合計の両方が含まれ、あなたがあなたの「偽」の次元にカウント情報を追加できるように、同じグループにカウントしたいですあなたのテーブルのために使用されています
var poGroup = reductio()
.sum('total')
.count(true)(poDimension.group());
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.sum > 0; })
.map(function (d) {
var currPo = pos.filter(function (g) { return g.PO === d.key; })[0];
return {
PO: d.key,
total: d.value.sum,
count: d.value.count,
Surgeon: currPo.Surgeon,
Levels: currPo.Levels,
date: currPo.date
};
});
}
};
次に、あなたのテーブルにあなたはすでに同様のカウントの合計のためにやっていることを行うことができます:
nasdaqTable /* dc.dataTable('.dc-data-table', 'chartGroup') */
.dimension(uniqueDim)
// Data table does not use crossfilter group but rather a closure
// as a grouping function
.group(function (d) {
d.cpl = "$" + (d.total/d.Levels).toFixed(2);
d.countperLevel = (d.count/d.Levels).toFixed(2);
d.total = "$" + d.total.toFixed(2);
return d.Surgeon;
})
// (_optional_) max number of records to be shown, `default = 25`
.size(1000)
// There are several ways to specify the columns; see the data-table documentation.
// This code demonstrates generating the column header automatically based on the columns.
.columns([
'date', 'PO', 'Surgeon', 'Levels', 'total', 'count', { label: "Cost per Level", format: function (d) { return d.cpl }}, { label: "Count per Level", format: function(d) { return d.countperLevel; }}
])
私はあなたが本当にあなたの値を事前に計算するためにあなたのテーブルにgroup
を使用する必要があるかわかりません。おそらくフォーマット関数で直接計算するのが良いでしょうが、どちらの方法でも動作するはずです。
例:またhttps://jsfiddle.net/optgf9d3/
、Reductioであなたがvalue
構文を使用して、同じグループに(異なる性質上例外カウントを含む)集計の任意の番号を持つことができます。これは、同じグループに基づいてさまざまな種類のレート計算を行う必要がある場合に便利です。https://github.com/crossfilter/reductio#aggregations-standard-aggregations-reductio-b-value-b-i-propertyname-i-
お返事ありがとうございました!私はあなたが何をしているのかを見ていますが、集計はきちんと出てこないのです。 PO 50047738は、生データを調べる合計カウントが20です。なぜそれが11まで増えているのか分かりません – Wesley
何が起きているのか分かります。表示される番号11は、PO 50047738がデータベースで使用する行の合計数です。表示するカウント数は、そのPOのディメンションの合計のQTYで、20でなければなりません。 – Wesley
ああ、ありがとうございます。だからあなたは数量に別の金額が必要ですか?その場合はReductioの値構文を使用し、追加の合計を定義します。 –