MCPcopy
hub / github.com/apache/echarts / applySingleDataTransform

Function applySingleDataTransform

src/data/helper/transform.ts:392–539  ·  view source on GitHub ↗
(
    transOption: DataTransformOption,
    upSourceList: Source[],
    infoForPrint: { datasetIndex: number },
    // If `pipeIndex` is null/undefined, no piped transform.
    pipeIndex: number
)

Source from the content-addressed store, hash-verified

390}
391
392function applySingleDataTransform(
393 transOption: DataTransformOption,
394 upSourceList: Source[],
395 infoForPrint: { datasetIndex: number },
396 // If `pipeIndex` is null/undefined, no piped transform.
397 pipeIndex: number
398): Source[] {
399 let errMsg = '';
400 if (!upSourceList.length) {
401 if (__DEV__) {
402 errMsg = 'Must have at least one upstream dataset.';
403 }
404 throwError(errMsg);
405 }
406 if (!isObject(transOption)) {
407 if (__DEV__) {
408 errMsg = 'transform declaration must be an object rather than ' + typeof transOption + '.';
409 }
410 throwError(errMsg);
411 }
412
413 const transType = transOption.type;
414 const externalTransform = externalTransformMap.get(transType);
415
416 if (!externalTransform) {
417 if (__DEV__) {
418 errMsg = 'Can not find transform on type "' + transType + '".';
419 }
420 throwError(errMsg);
421 }
422
423 // Prepare source
424 const extUpSourceList = map(upSourceList, upSource => createExternalSource(upSource, externalTransform));
425
426 const resultList = normalizeToArray(
427 externalTransform.transform({
428 upstream: extUpSourceList[0],
429 upstreamList: extUpSourceList,
430 config: clone(transOption.config)
431 })
432 );
433
434 if (__DEV__) {
435 if (transOption.print) {
436 const printStrArr = map(resultList, extSource => {
437 const pipeIndexStr = pipeIndex != null ? ' === pipe index: ' + pipeIndex : '';
438 return [
439 '=== dataset index: ' + infoForPrint.datasetIndex + pipeIndexStr + ' ===',
440 '- transform result data:',
441 makePrintable(extSource.data),
442 '- transform result dimensions:',
443 makePrintable(extSource.dimensions)
444 ].join('\n');
445 }).join('\n');
446 log(printStrArr);
447 }
448 }
449

Callers 1

applyDataTransformFunction · 0.85

Calls 11

throwErrorFunction · 0.90
normalizeToArrayFunction · 0.90
makePrintableFunction · 0.90
logFunction · 0.90
detectSourceFormatFunction · 0.90
createSourceFunction · 0.90
createExternalSourceFunction · 0.85
cloneFunction · 0.85
isSupportedSourceFormatFunction · 0.85
isObjectFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…