MCPcopy Index your code
hub / github.com/microsoft/SandDance / aggregateParams

Function aggregateParams

docs/app/js/sanddance-app.js:118122–118134  ·  view source on GitHub ↗
(_, pulse)

Source from the content-addressed store, hash-verified

118120// First collect all unique pivot field values.
118121// Then generate aggregate fields for each output pivot field.
118122function aggregateParams(_, pulse) {
118123 const key = _.field, value = _.value, op = (_.op === "count" ? "__count__" : _.op) || "sum", fields = (0, _vegaUtil.accessorFields)(key).concat((0, _vegaUtil.accessorFields)(value)), keys = pivotKeys(key, _.limit || 0, pulse); // if data stream content changes, pivot fields may change
118124 // flag parameter modification to ensure re-initialization
118125 if (pulse.changed()) _.set("__pivot__", null, null, true);
118126 return {
118127 key: _.key,
118128 groupby: _.groupby,
118129 ops: keys.map(()=>op),
118130 fields: keys.map((k)=>get(k, key, value, fields)),
118131 as: keys.map((k)=>k + ""),
118132 modified: _.modified.bind(_)
118133 };
118134} // Generate aggregate field accessor.
118135// Output NaN for non-existent values; aggregator will ignore!
118136function get(k, key, value, fields) {
118137 return (0, _vegaUtil.accessor)((d)=>key(d) === k ? value(d) : NaN, fields, k + "");

Callers 1

transformFunction · 0.70

Calls 3

pivotKeysFunction · 0.70
getFunction · 0.70
setMethod · 0.45

Tested by

no test coverage detected