我陷入了困境,我需要通过使用其他两个维度索引的数据来查找一维数据的总和。
示例:
"mode_device","method","discount","time","first_time","paid","p_id","p_sku"
"Desktop","EBS",,"1344887090","1344887090","1079","8786","PPLB03571285"
"Desktop","MOBIKWIK-WALLET","89","1474371140","1474371140","591","99068","PPLB009DCBBFREE"
"AndroidApp","COD","97","1474371149","1438844849","647","72321","PPLB034601"
"Desktop","JUSPAY","60","1474371158","1474371158","398","92389","PPLB713SQ306"
"AndroidApp","COD","190","1474371247","1448993680","1261","72685","PLB0029regenerist3"
"Desktop","JUSPAY","90","1474371346","1474371346","599","86728","PPLB66719804817"
"Desktop","DEBITCARD","60","1474371366","1465733603","398","92389","PPLB713SQ306"
"AndroidApp","COD","0","1474371404","1474371404","577","106032","PPLB0335PA0990NM"
"Desktop","COD","43","1474371404","1468956726","356","13221","PPLB039605"
我们在此处比较mode_device
和method
,我们必须从付费中返回数据的总和。
实施例: AndroidApp和COD可能会重复多次让我们说数据类似于
"Android","COD","234"
"Android","Ebs","234"
"Ios","COD","234"
"Ios","COD","234"
"Android","COD","234"
我们必须像
一样返回Android-COD:468
Android-Ebs:234
Ios-COD:468
使用dc.js图表。
答案 0 :(得分:0)
我从你的问题中不清楚你想如何绘制这些数据 - 它是一个条形图,其条形图标有两个字段吗?
但是,如果您想同时按mode_device
和method
进行汇总,则只需创建一个在其键中使用这两个值的维度:
var modeMethodDimension = cf.dimension(function(d) { return [d.mode_device, d.method].join('-'); });
var modeMethodGroup = modeMethodDimension.group(function(d) { return +d.paid; });
现在该组应该具有键值对,如
[{key: 'Android-COD', value: 468}, {key: 'Android-Ebs', value: 234}, ...]
如果你将它放入dc.barChart
那些键就是条形码的名称。