MCPcopy
hub / github.com/tdewolff/minify / prepareBoxplotData

Function prepareBoxplotData

_benchmarks/sample_echarts.js:64284–64321  ·  view source on GitHub ↗

* See: * * * * Helper method for preparing data. * * @param rawData like * [ * [12

(rawData, opt)

Source from the content-addressed store, hash-verified

64282 */
64283
64284 function prepareBoxplotData(rawData, opt) {
64285 opt = opt || {};
64286 var boxData = [];
64287 var outliers = [];
64288 var boundIQR = opt.boundIQR;
64289 var useExtreme = boundIQR === 'none' || boundIQR === 0;
64290
64291 for (var i = 0; i < rawData.length; i++) {
64292 var ascList = asc(rawData[i].slice());
64293 var Q1 = quantile(ascList, 0.25);
64294 var Q2 = quantile(ascList, 0.5);
64295 var Q3 = quantile(ascList, 0.75);
64296 var min = ascList[0];
64297 var max = ascList[ascList.length - 1];
64298 var bound = (boundIQR == null ? 1.5 : boundIQR) * (Q3 - Q1);
64299 var low = useExtreme ? min : Math.max(min, Q1 - bound);
64300 var high = useExtreme ? max : Math.min(max, Q3 + bound);
64301 var itemNameFormatter = opt.itemNameFormatter;
64302 var itemName = isFunction(itemNameFormatter) ? itemNameFormatter({
64303 value: i
64304 }) : isString(itemNameFormatter) ? itemNameFormatter.replace('{value}', i + '') : i + '';
64305 boxData.push([itemName, low, Q1, Q2, Q3, high]);
64306
64307 for (var j = 0; j < ascList.length; j++) {
64308 var dataItem = ascList[j];
64309
64310 if (dataItem < low || dataItem > high) {
64311 var outlier = [itemName, dataItem];
64312 outliers.push(outlier);
64313 }
64314 }
64315 }
64316
64317 return {
64318 boxData: boxData,
64319 outliers: outliers
64320 };
64321 }
64322
64323 var boxplotTransform = {
64324 type: 'echarts:boxplot',

Callers 1

sample_echarts.jsFile · 0.85

Calls 4

ascFunction · 0.85
quantileFunction · 0.70
isFunctionFunction · 0.70
isStringFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…