here is my sample fiddle
It is a 2 basic chart dc.js charts. What I am trying to understand is how the charts interact with each other. For instance:
If i select Aziz
on the row chart(on the right chart) the other values in this chart are greyed out and in the ring chart(left chart) 2012
fills up the whole Ring Chart. Then if i select Aziz
again the both charts are reset.
If I select 2012
on the ring chart(on the left chart) the other values in this chart are greyed out and in the row chart(right chart) Aziz
is the only value shown in the row chart(right chart). Then if i select 2012
again the both charts are reset.
Basically how is this interaction working?
The four variables being passed to these charts are yearDim
spendDim
spendPerYear
spendPerName
but the only commonality here is xfilter
maybe that's what it is, but that does not fully explain it for me. Can anyone advise to help me understand this better?
var xfilter = crossfilter(data1),
yearDim = xfilter.dimension(function(d) {return +d.Year;}),
spendDim = xfilter.dimension(function(d) {return Math.floor(d.Spent/10);}),
nameDim = xfilter.dimension(function(d) {return d.Name;}),
spendPerYear = yearDim.group().reduceSum(function(d) {return +d.Spent;}),
spendPerName = nameDim.group().reduceSum(function(d) {return +d.Spent;});
function render_plots(){
yearRingChart
.width(200).height(200)
.dimension(yearDim)
.group(spendPerYear)
.innerRadius(50);
spenderRowChart
.width(250).height(200)
.dimension(nameDim)
.group(spendPerName)
.elasticX(true);
dc.renderAll();
}
NOTE
here and here might be related, it's on charts interactivity or not being linked.
good chart example in an answer here
EDIT1
see this fiddle
with the 2nd graph if I change this line .group(spendPerName)
to this .group(spendPerYear)
I would now be grouping by the same grouping on both the charts. this changes the charts interactivity.
Now I can select 2012 on the row chart and it will be highlighted. And I can toggle this from highlighted to unhighlighted. But when it is highlighted and I select another year in the row chart, they all collapse(dissapear). All the while nothing is happening on the ring chart.
With the ring chart I can select a year, and it will be highlighted, toggling this will highlight the year, then the whole ring. But again all the while nothing is happening on the row chart.
So it effectively has lost the interactivity. This is probably a silly example but it might help me understand it a bit better. why has it lost the interactivity? Or put another way, how can I present the data the same way in the graphs and not lose the interactivity? So if I select 2012 on the row chart this would be highlighted (or be shown as the whole ring) on the ring chart? maybe it is to do with my dataset.
might be useful: Why are some of my charts not filtering?