d3.js - why does one chart not filter another in dc.js? -
i not able understand how dc groups chart. change in 1 filter reflects in others. have simple code 2 series charts. when draw brush on one, not filter other. not sure why ? can please have quick @ small code , 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(); });
you using same dimension group on both charts.
a grouping intersects crossfilter's current filters, except associated dimension's filter. thus, group methods consider records satisfy every filter except dimension's filter. so, if crossfilter of payments filtered type , total, group total observes filter type.
from crossfilter api doc
one solution create rundimension2
similar rundimension
, second chart using dimension instead.
Comments
Post a Comment