My JSON looks like this (with some extra records that I'm not including for brevity)
[{"name":"Jim","category":"TechSupport","month":"8",year:"2012","Date":"2012-08-01T04:00:00.000Z", "TechSupport":2,"Management":0,"Sales":0},
{"name":"Jim","category":"Management","month":"8",year:"2012","Date":"2012-08-01T04:00:00.000Z", "TechSupport":0,"Management":3,"Sales":0}]
My stack looks like this
var stack = d3.stack().keys(["TechSupport", "Management", "Sales"])
var series = stack(data)
The results of my stack look like [[0,2],[0,0]],[[2,2],[3,3]],[[1,1],[3,3]]
My code for displaying the barchart over the timescale looks like this
var groups = mainChart.selectAll("g")
.data(series)
.append("g")
groups.selectAll("rect")
.attr("id","bar")
.attr("fill", function(d){return colors(d.data.category)})
.attr("x", function(d){return xScale(d.data.Date);}}
.attr("y", function(d){return yScale(d[1]);})
.attr("width", 20)
.attr("height" return yScale(d[0]) - yScale(d[1])})
I can get everything to display along the timeline correctly except when I have items that have the same date, those are not stacking and I'm not sure why?