Skip to content Skip to sidebar Skip to footer

Dc And Crossfilter - Calculating Percentage Within Records

I'm trying to calculate and plot percentage (%) in one of my dc charts. I have read the API and multiple examples regarding reduce functions (add, remove & init etc) I referred

Solution 1:

The numbers are in string format, had to be parsed into integer for the functions to read them, the values were junk as it was concatenating them.

Solution code :

function(p, v) {
        ++p.count;
        p.total += parseInt(v.recharge_revenue);
        //p.percent = p.count ? p.decay/p.total : 0;console.log(p.total);
        return p;
    },
    //removefunction(p, v) {
        --p.count;
        p.total -= parseInt(v.recharge_revenue);
        return p;
    }

Post a Comment for "Dc And Crossfilter - Calculating Percentage Within Records"