You might need to have for ... in loops to build that object in your innerColumns like this:

itemLookup= data[0],
category = d3.keys(itemLookup.category),
items = d3.keys(itemLookup.category[type1[0]]),
columnHeaders = [],
innerColumns = (function(){
  var result = {};
  for(var i = 0, ii = category.length; i<ii; i++){
    var holder = [];
    for(var j = 0, jj = items.length; j<jj; j++){
      result[category[i]] = holder;
  return result;

You can refer to this for reference:


I have tried to achieve grouped stacked bar chart using d3.stack(). Here are 2 important parts of my solution:

var datasets=[d3.stack().keys(['type1','type3'])(data),

var num_groups=datasets.length;

Here I am using .keys() method of d3.stack to create datasets for each group. After this we can use the code for creating stacked bar chart like this:

d3.range(num_groups).forEach(function(gnum) {
                .attr('class', 'group'+gnum)

You can see the complete solution here:

Related Query

More Query from same tag