1

Working on a grails application, wherein I am using dc-crossfilter to plot 5 bar graphs which are interconnected to each other.

Now, I want to do a simple thing here : In my first bar graph, there are 14 bars ( x number of departments and 1 "All" graph) Graph

So the problem here is that the presence of "All" in the graph really messes up every other department's number as they are way too low (All is summation of all x number of departments) So each department number is so low that it's not even visible clearly.

But, it is very important to load the data for "All", as all the remaining 4 bar charts are filtered for "All" only.

So, is there any way how I can hide "All" in my first bar graph even though data is loaded? Is this even feasible?

There has to be some simple workaround to do this.

All approaches/suggestions are most welcome.

UPDATE :

Code:

This is the part where I define the groups and dimensions

 var devValue = facts.dimension(function (d) {return d.c;});
      var devValueGroupSum = devValue.group().reduceSum(function(d) { return +d.g;});

      var mvValue = facts.dimension(function(d,i) {return d.b;});
      var mvValueGroupSum = mvValue.group().reduceSum(function(d) {return +d.g;});

Now, where and how exactly do I define a fake group and prefilter the data. But will "ALL" be included in the actual dataset ( and not visualization part) even after prefiltering the data.

Code for fake group as in documentation :

var group = {
   all:function () {
    var cumulate = 0;
    var g = [];
    _group.all().forEach(function(d,i) {
      cumulate += d.value;
      g.push({key:d.key,value:cumulate})
    });
    return g;
   }
 };

I am really not able to understand the documentation as in how to implement this, can you help me in implementing this?

Pravin
  • 461
  • 5
  • 26

1 Answers1

1

You can use a "fake group" to prefilter the data. Whenever the chart fetches the data it will go through your fake group, which then fetches the data from the real group and changes it.

The technique is described in the FAQ.

Gordon
  • 19,811
  • 4
  • 36
  • 74
  • I have repeatedly read the documentation on fake groups and am unable to understand that, can you pls elaborate on the implementation part of fake groups etc. See updated answer – Pravin Aug 04 '14 at 11:44
  • I tried to give an explanation to "fake groups" here: http://stackoverflow.com/questions/17524627/is-there-a-way-to-tell-crossfilter-to-treat-elements-of-array-as-separate-record/24659988#24659988. Notice how I filtered the "all" key before returning the results. – DJ Martin Aug 04 '14 at 13:33
  • You would create the fake group to wrap the original group, and pass in the fake group instead of the original. Your use case would be almost just like the second example there. (`group.all` has a completely different meaning from your ALL bin, it just means "fetch results".) Let me see if I can clarify the FAQ somehow. – Gordon Aug 06 '14 at 13:45
  • @Gordon, it worked. Thanks guys. Used the code from FAQ and removed cumulate and made it a simple function as shown in the example by DJ Martin. – Pravin Aug 07 '14 at 09:36