Dc.js - How To Group By Unique Id
I'm using dc.js and crossfilter to create 3 rowcharts from a csv. The first two are straighforward but the third one needs to have a dimension set to multiple columns of my input c
Solution 1:
Your example is a slightly simpler example because you don't have an array for "rowchart3" values but the solution could still work for you.
The answer includes a jsfiddle that demonstrates how to manually manage the categories in the chart. You would need to change
function reduceAdd(p, v) {
if (v.topics[0] === "") return p; // skip empty values
v.topics.forEach (function(val, idx) {
p[val] = (p[val] || 0) + 1; //increment counts
});
return p;
}
to something like
functionreduceAdd(p, v) {
if(v.rowhart3a != "")
p[v.rowchart3a] = (p[v.rowchart3a] || 0) + 1; //increment countsif(v.rowhart3b != "")
p[v.rowchart3b] = (p[v.rowchart3b] || 0) + 1; //increment countsif(v.rowhart3c != "")
p[v.rowchart3c] = (p[v.rowchart3c] || 0) + 1; //increment countsreturn p;
}
I hope this helps. -DJ
Post a Comment for "Dc.js - How To Group By Unique Id"