score:1

So there are a couple things going on in this question, so I'll try to separate them:

Crossfilter works with tidy data

http://vita.had.co.nz/papers/tidy-data.pdf

This means that you will need to come up with a naive method of filling in the nulls you're seeing (or if need be, in your initial query of the data, omit the nulled values. If you want to get really fancy, you could even infer the null values based off of other data. Whatever your solution, you need to make your data tidy prior to putting it into crossfilter.

Groups and Filtering Operations

txnVolByCurrcode = txnByCurrcode.group().reduceSum(function(d) {
    if(d.GROUPING_ID ===1) {
        return d.TXNCOUNT;
    } else {
        return 0;
    }
});

This is a filtering operation done on the reduction. This is something that you should separate. Allow that filtering to occur elsewhere (either in the visual, crossfilter itself, or in the query on the data).

This means your reduceSum's become:

var txnVolByCurrcode = txnByCurrcode.group().reduceSum(function(d) {
    return d.TXNCOUNT;
});

And if you would like the user to select which group to display:

var groupId = cfdata.dimension(function(d) { return d.GROUPING_ID; });
var groupIdGroup = groupId.group(); // this is an interesting name
dc.pieChart("#group-chart")
    .width(250)
    .height(250)
    .radius(125)
    .innerRadius(50)
    .transitionDuration(750)
    .dimension(groupId)
    .group(groupIdGroup)
    .renderLabel(true);

For an example of this working: http://jsfiddle.net/b67pX/


Related Query