score:0

I'll just repeat what I said above: What I noticed was that to create a crossfilter from another crossfilter, the best thing is to have your reduce function store the set of data objects you want in the next crossfilter create a data array from which to create the next crossfilter. This resolved the lag.

So this: foodProbingCookedGroup = foodIdDimension.group().reduce( // callback for when items are added to the results. function (p,v){ if (p.firstProbeTime == null){ p.firstProbeTime = v.dd; p.lastProbeTime = v.dd; p.probed_food_name = v.probed_food_name; } p.finalProbeTime = v.dd; p.lifeInMinutes = (v.dd.getTime() - p.firstProbeTime.getTime()) / 60000;

            p.stationLife.push({
                staff_name : v.staff_name, 
                probed_food_name: v.probed_food_name,
                minutesAtPreviousStation : (v.dd.getTime()-p.firstProbeTime.getTime()) / 60000,
                previous_station_name : p.previous_station_name,
                currentProbeTime : v.dd,
                temperature : v.probed_food_history_temperature,
                station_name : v.station_name,
                station_type : v.station_type 
            });
            p.previous_station_name = v.station_name;
            return p;
        },
        // Callback for when deleted
        function (p,v){
            // Do nothing.
            return p;
        },
        // Initialise function
        function (){
            return ({
                firstProbeTime: null,
                lastProbeTime: null,
                finalProbeTime: null,
                lifeInMinutes: 0,
                probed_food_name: "",
                previous_station_name: "",
                stationLife: [] 
            });
        }
    );

Then on the range chart you add this:

        .on("postRedraw", function (chart) {renderFoodTimeChards(chart);});

Then the function does the following: function renderFoodTimeChards (filterChart) {

    var data = [];

    var foodGroup;
    //Get the range of the filtered data.
    if (typeof filterChart == 'undefined' || filterChart.filter() === null ){
        foodGroup = foodProbingCookedGroup.top(Infinity);
    }
    else{
        var fromDate = filterChart.filter()[0].getTime();
        var toDate = filterChart.filter()[1].getTime();
        foodGroup = foodProbingCookedGroup.top(Infinity).filter(function(d){
            var timeToCheck = d.value.firstProbeTime.getTime();
            return ( timeToCheck >= fromDate && timeToCheck <= toDate)
        });

    }
    // Derive the set of data we need. 
    foodGroup.forEach(function (d){
        data = data.push({
            probed_food_name: d.value.probed_food_name,
            lifeInMinutes : d.value.lifeInMinutes
        });
    })

    crossStore["foodLifeStore"] = crossfilter(data);

Related Query

More Query from same tag