(data, sourceFormat, seriesLayoutBy, sourceHeader, dimensionsDefine)
| 20735 | |
| 20736 | // return {startIndex, dimensionsDefine, dimensionsCount} |
| 20737 | function 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 | } |
no test coverage detected