javascript - dc.js: Reducing rows in data table -


so have data.table object being outputed this:

gender  hair-color  pets  group1.totals   group2.totals   group3.totals   f       black      y       10               0                 0   f       black      y        0               7                 0   f       black      y        0               0                 8 

how collapse this?

  gender  hair-color  pets  group1.totals   group2.totals   group3.totals     f       black      y         10               7                 8 

i have tried reducing dimensions doesn't seem work. code below:

ndx = crossfilter(data); datatable = dc.datatable('#data-table'); var tabledim = ndx.dimension(function(d) {     return d.gender + "/" + d.hair-color + "/" + d.pets;       });  datatable    .width(400)    .height(800)    .dimension(tabledim)    .group(function(d){      return "data counts";     }),    .columns([       function(d) {         return d.gender;        },       function(d) {         return d.hair-color;        },       function(d) {         return d.pets;       }       function(d) {         if (d.group == 1) return d.totals;           else return 0;       },       function(d) {         if (d.group == 2) return d.totals;           else return 0;       },       function(d) {         if (d.group == 3) return d.totals;           else return 0; 

essentially know have reduce , group data can't find have in order achieve. great, thanks!

use following code;

var ndx=crossfilter(data); var dimension=ndx.dimension(function(d){return d.hair-color}); var databyhaircolor=dimension.group().reducecount(); 

i hope it'll solve problem. if want other filtering option use that. used hair color. let me know if still facing issues


Comments

Popular posts from this blog

How to provide Authorization & Authentication using Asp.net, C#? -

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

android - Pass an Serializable object in AIDL -