OK followup question...
I now have my data nested and ready via the code:
d3.json("fastip-test.json", function(json) {
var dimensions = json.entries.map(function(d){return
d.dimensions;});
var nested = d3.nest().key(function(d) { return
d.protocolIdentifier; }).map(dimensions);
}
but I'm now trying to use that to populate layers for the stacked bar
chart. My code is as follows:
d3.json("fastip-test.json", function(json) {
var dimensions = json.entries.map(function(d){return
d.dimensions;});
var nested = d3.nest().key(function(d) { return
d.protocolIdentifier; }).map(dimensions);
var chart = d3.select("body").append("svg:svg")
.attr("class", "chart")
.attr("width", w * (dimensions.length - 1))
.attr("height", h);
var layers =
chart.selectAll("g.layer").data(nested).enter().append("svg:g")
.attr("fill", function(d, i) { return color(i / (4)); })
.attr("class", "layer");
}
But layers var is empty. I expect this is because "nested" is an
object and that d3 can't iterate through it easily. I've tried
writing a function for data, like so:
var layers = chart.selectAll("g.layer").data(function(d){
for (var key in nested) {
layers[d] = nested[key];
return d;
//return nested[key];
}
}).enter().append("svg:g")
.attr("fill", function(d, i) { return color(i / (4)); })
.attr("class", "layer");
But this doesn't seem to give me what I need. Any tips to get this
data into layers greatly appreciated.