MCPcopy Index your code
hub / github.com/plotly/plotly.js / aggregateOneArray

Function aggregateOneArray

src/transforms/aggregate.js:250–270  ·  view source on GitHub ↗
(gd, trace, groupings, aggregation)

Source from the content-addressed store, hash-verified

248};
249
250function aggregateOneArray(gd, trace, groupings, aggregation) {
251 if(!aggregation.enabled) return;
252
253 var attr = aggregation.target;
254 var targetNP = Lib.nestedProperty(trace, attr);
255 var arrayIn = targetNP.get();
256 var conversions = Axes.getDataConversions(gd, trace, attr, arrayIn);
257 var func = getAggregateFunction(aggregation, conversions);
258
259 var arrayOut = new Array(groupings.length);
260 for(var i = 0; i < groupings.length; i++) {
261 arrayOut[i] = func(arrayIn, groupings[i]);
262 }
263 targetNP.set(arrayOut);
264
265 if(aggregation.func === 'count') {
266 // count does not depend on an input array, so it's likely not part of _arrayAttrs yet
267 // but after this transform it most definitely *is* an array attribute.
268 Lib.pushUnique(trace._arrayAttrs, attr);
269 }
270}
271
272function getAggregateFunction(opts, conversions) {
273 var func = opts.func;

Callers 1

aggregate.jsFile · 0.85

Calls 2

getAggregateFunctionFunction · 0.85
funcFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…