Trying to do the same here but not getting it working. Assuming the correct way to do this is in the preRedraw() handler as follows:
statusPerWardChart\
.width(w)
.height(h)
.margins({top: 20, left: 40, right: 10, bottom: 60})
.group(statusPerWard,"Functional")
.dimension(wards)
.ordering((d) -> -d.value.functional / d.value.count)
.valueAccessor((p) -> p.value.functional)
.stack(statusPerWard, "Needs Repair", (d) -> d.value["needs repair"])
.stack(statusPerWard, "Not Functional", (d) -> d.value["not functional"])
.x(d3.scale.ordinal())
.xUnits(dc.units.ordinal)
.elasticY(true)
.elasticX(true)
.renderlet((chart) ->
chart.selectAll("g.x text")
.attr('dx', '-30')
.attr('transform', "rotate(-65)"))
.label((d) -> d.key)
.title((d) ->
d.key +
"\nFunctional: " + d.value.functional +
"\nNot functional: " + d.value["needs repair"])
.legend(dc.legend().x(w-100).y(10))
.on("preRedraw", (chart) ->
group = chart.group()
group2 = {
all: () ->
group.all().filter((d) -> d.value.count > 0)
}
chart.group(group2))
.on("preRender", (chart) ->
chart.rescale())
Before:
Verifying group2 in the console shows it should be fine. However it seems only one stack layer is filtered? Whats going on?
Using current master.