I am not able to understand how dc groups chart. So that the change in one filter reflects in all others.
I have a simple code with two series charts. When I draw brush on one, it does not filter the other. Not sure why ? Can someone please have a quick look at the small code and suggest.
d3.csv("data/compareData.txt", function(data) {
ndx = crossfilter(data);
runDimension = ndx.dimension(function(d) {return [+d3.time.format.iso.parse(d.timestamp), +d.meterid]; });
frequencyGroup = runDimension.group().reduceSum(function(d) { return +d.frequency; });
magnitudeGroup = runDimension.group().reduceSum(function(d) { return +d.magnitude; });
frequencyChart
.width(768)
.height(480)
.chart(function(c) { return dc.lineChart(c).interpolate('basis'); })
.x(d3.time.scale().domain([1366621166000, 1366621179983]))
.y(d3.scale.linear().domain([90, 100]))
.brushOn(true)
.yAxisLabel("Measured Speed km/s")
.xAxisLabel("Run")
.elasticY(true)
.dimension(runDimension)
.group(frequencyGroup)
.mouseZoomable(false)
.seriesAccessor(function(d) {return +d.key[1];})
.keyAccessor(function(d) {return +d.key[0];})
.valueAccessor(function(d) {return +d.value;})
.legend(dc.legend().x(350).y(350).itemHeight(13).gap(5).horizontal(1).legendWidth(140).itemWidth(70));
frequencyChart.yAxis().tickFormat(function(d) {return d3.format(',d')(d);});
frequencyChart.margins().left += 40;
magnitudeChart
.width(768)
.height(480)
.chart(function(c) { return dc.lineChart(c).interpolate('basis'); })
.x(d3.time.scale().domain([1366621166000, 1366621179983]))
.y(d3.scale.linear().domain([90, 100]))
.brushOn(true)
.yAxisLabel("Measured Speed km/s")
.xAxisLabel("Run")
.elasticY(true)
.dimension(runDimension)
.group(magnitudeGroup)
.mouseZoomable(false)
.seriesAccessor(function(d) {return +d.key[1];})
.keyAccessor(function(d) {return +d.key[0];})
.valueAccessor(function(d) {return +d.value;})
.legend(dc.legend().x(350).y(350).itemHeight(13).gap(5).horizontal(1).legendWidth(140).itemWidth(70));
magnitudeChart.yAxis().tickFormat(function(d) {return d3.format(',d')(d);});
magnitudeChart.margins().left += 40;
dc.renderAll();
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…