MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / completeBySourceData

Function completeBySourceData

libs/echarts/echarts.simple.js:20737–20811  ·  view source on GitHub ↗
(data, sourceFormat, seriesLayoutBy, sourceHeader, dimensionsDefine)

Source from the content-addressed store, hash-verified

20735
20736// return {startIndex, dimensionsDefine, dimensionsCount}
20737function completeBySourceData(data, sourceFormat, seriesLayoutBy, sourceHeader, dimensionsDefine) {
20738 if (!data) {
20739 return {dimensionsDefine: normalizeDimensionsDefine(dimensionsDefine)};
20740 }
20741
20742 var dimensionsDetectCount;
20743 var startIndex;
20744
20745 if (sourceFormat === SOURCE_FORMAT_ARRAY_ROWS) {
20746 // Rule: Most of the first line are string: it is header.
20747 // Caution: consider a line with 5 string and 1 number,
20748 // it still can not be sure it is a head, because the
20749 // 5 string may be 5 values of category columns.
20750 if (sourceHeader === 'auto' || sourceHeader == null) {
20751 arrayRowsTravelFirst(function (val) {
20752 // '-' is regarded as null/undefined.
20753 if (val != null && val !== '-') {
20754 if (isString(val)) {
20755 startIndex == null && (startIndex = 1);
20756 }
20757 else {
20758 startIndex = 0;
20759 }
20760 }
20761 // 10 is an experience number, avoid long loop.
20762 }, seriesLayoutBy, data, 10);
20763 }
20764 else {
20765 startIndex = sourceHeader ? 1 : 0;
20766 }
20767
20768 if (!dimensionsDefine && startIndex === 1) {
20769 dimensionsDefine = [];
20770 arrayRowsTravelFirst(function (val, index) {
20771 dimensionsDefine[index] = val != null ? val : '';
20772 }, seriesLayoutBy, data);
20773 }
20774
20775 dimensionsDetectCount = dimensionsDefine
20776 ? dimensionsDefine.length
20777 : seriesLayoutBy === SERIES_LAYOUT_BY_ROW
20778 ? data.length
20779 : data[0]
20780 ? data[0].length
20781 : null;
20782 }
20783 else if (sourceFormat === SOURCE_FORMAT_OBJECT_ROWS) {
20784 if (!dimensionsDefine) {
20785 dimensionsDefine = objectRowsCollectDimensions(data);
20786 }
20787 }
20788 else if (sourceFormat === SOURCE_FORMAT_KEYED_COLUMNS) {
20789 if (!dimensionsDefine) {
20790 dimensionsDefine = [];
20791 each$1(data, function (colArr, key) {
20792 dimensionsDefine.push(key);
20793 });
20794 }

Callers 1

prepareSourceFunction · 0.70

Calls 9

pushMethod · 0.80
arrayRowsTravelFirstFunction · 0.70
isStringFunction · 0.70
each$1Function · 0.70
getDataItemValueFunction · 0.70
isArrayFunction · 0.70
assert$1Function · 0.70

Tested by

no test coverage detected