src/transforms/aggregate.js
function group (frame) {
        let v, name, op;
        const entries = fields.map((field, index) => {
            name = ops[index];
            op = scalar_operations.get('count');
            if (name) {
                op = scalar_operations.get(name);
                if (!op) {
                    op = scalar_operations.get('count');
                    warn(`Operation ${name} is not supported, use count`);
                }
            }
            return {
                field: field,
                as: as[index] || field,
                op: op
            };
        });

        return frame.dimension(groupby).group().reduce((o, record) => {
            return entries.reduce((oo, entry) => {
                v = 0;
                if (entry.as in oo) v = oo[entry.as];
                oo[entry.as] = entry.op(v, record[entry.field]);
                return oo;
            }, o);
        }, null, Object).all().map(d => {
            d.value[groupby] = d.key;
            return d.value;
        });
    }
function group (frame) {
        let v, name, op;
        const entries = fields.map((field, index) => {
            name = ops[index];
            op = scalar_operations.get('count');
            if (name) {
                op = scalar_operations.get(name);
                if (!op) {
                    op = scalar_operations.get('count');
                    warn(`Operation ${name} is not supported, use count`);
                }
            }
            return {
                field: field,
                as: as[index] || field,
                op: op
            };
        });

        return frame.dimension(groupby).group().reduce((o, record) => {
            return entries.reduce((oo, entry) => {
                v = 0;
                if (entry.as in oo) v = oo[entry.as];
                oo[entry.as] = entry.op(v, record[entry.field]);
                return oo;
            }, o);
        }, null, Object).all().map(d => {
            d.value[groupby] = d.key;
            return d.value;
        });
    }
function group ( frame ) { let v , name , op ; const entries = fields . map ( ( field , index ) => { name = ops [ index ] ; op = scalar_operations . get ( 'count' ) ; if ( name ) { op = scalar_operations . get ( name ) ; if ( ! op ) { op = scalar_operations . get ( 'count' ) ; warn ( ` ${ name } ` ) ; } } return { field : field , as : as [ index ] || field , op : op } ; } ) ; return frame . dimension ( groupby ) . group ( ) . reduce ( ( o , record ) => { return entries . reduce ( ( oo , entry ) => { v = 0 ; if ( entry . as in oo ) v = oo [ entry . as ] ; oo [ entry . as ] = entry . op ( v , record [ entry . field ] ) ; return oo ; } , o ) ; } , null , Object ) . all ( ) . map ( d => { d . value [ groupby ] = d . key ; return d . value ; } ) ; }
Perform aggregation with a set of data fields to group by
Perform aggregation with a set of data fields to group by