JavaScript dc.js: Reducing rows in data table

So I have a data.table object that is being outputed like 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 do I collapse it so that it will be like this?

  gender  hair-color  pets  group1.totals   group2.totals   group3.totals
    F       black      Y         10               7                 8

I have tried reducing the dimensions but it doesn't seem to work. My code is 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 I know that I have to reduce and group my data but I can't find specifically what I have to do in order to achieve. Any help would be great, thanks!

Answer:1

I am working on code written by someone else. To my knowledge its not correct but I am not seeing any errors and so now I am not sure if something changed since version 8. The code is as below & ...

I am working on code written by someone else. To my knowledge its not correct but I am not seeing any errors and so now I am not sure if something changed since version 8. The code is as below & ...

I am using AngularJS with MVC file structure. I have a data structure in my controller that I want to display on my view. I have a custom "indicators" directive. Each "title" belongs to an indicator ...

I am using AngularJS with MVC file structure. I have a data structure in my controller that I want to display on my view. I have a custom "indicators" directive. Each "title" belongs to an indicator ...

I want to put my JSON data into Vue data, and a display, why can't I get to work? compiled: function(){ var self = this; console.log('teste'); $.ajax({ url: 'js/fake-ws.json', ...

I want to put my JSON data into Vue data, and a display, why can't I get to work? compiled: function(){ var self = this; console.log('teste'); $.ajax({ url: 'js/fake-ws.json', ...

  1. putting json data into html table
  2. putting json in database
  3. putting data into json object

Let's say I have a simple array like this: var myArr = [0,1,2,3,4,5,6,7,8,9] I'd like to extract a number of elements, starting from a specific index, like this: myArr.getElementsFromIndex(index, ...

Let's say I have a simple array like this: var myArr = [0,1,2,3,4,5,6,7,8,9] I'd like to extract a number of elements, starting from a specific index, like this: myArr.getElementsFromIndex(index, ...

  1. number elements from
  2. number elements in periodic table
  3. number elements in list python
  4. number elements in array python
  5. number elements in array matlab
  6. number elements in array javascript
  7. number elements in list r
  8. number elements in array c++
  9. number elements in numpy array
  10. number elements in array
  11. number elements in array perl
  12. number elements in each period
  13. number elements in a group
  14. number elements of matrix
  15. number of elements matlab
  16. number of elements python
  17. number of elements r
  18. number of elements numpy
  19. elements number of protons
  20. number of elements less than k