MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / detectSourceFormat

Function detectSourceFormat

libs/echarts/echarts-en.simple.js:20597–20639  ·  view source on GitHub ↗

* @see {module:echarts/data/Source} * @param {module:echarts/component/dataset/DatasetModel} datasetModel * @return {string} sourceFormat

(datasetModel)

Source from the content-addressed store, hash-verified

20595 * @return {string} sourceFormat
20596 */
20597function detectSourceFormat(datasetModel) {
20598 var data = datasetModel.option.source;
20599 var sourceFormat = SOURCE_FORMAT_UNKNOWN;
20600
20601 if (isTypedArray(data)) {
20602 sourceFormat = SOURCE_FORMAT_TYPED_ARRAY;
20603 }
20604 else if (isArray(data)) {
20605 // FIXME Whether tolerate null in top level array?
20606 if (data.length === 0) {
20607 sourceFormat = SOURCE_FORMAT_ARRAY_ROWS;
20608 }
20609
20610 for (var i = 0, len = data.length; i < len; i++) {
20611 var item = data[i];
20612
20613 if (item == null) {
20614 continue;
20615 }
20616 else if (isArray(item)) {
20617 sourceFormat = SOURCE_FORMAT_ARRAY_ROWS;
20618 break;
20619 }
20620 else if (isObject$1(item)) {
20621 sourceFormat = SOURCE_FORMAT_OBJECT_ROWS;
20622 break;
20623 }
20624 }
20625 }
20626 else if (isObject$1(data)) {
20627 for (var key in data) {
20628 if (data.hasOwnProperty(key) && isArrayLike(data[key])) {
20629 sourceFormat = SOURCE_FORMAT_KEYED_COLUMNS;
20630 break;
20631 }
20632 }
20633 }
20634 else if (data != null) {
20635 throw new Error('Invalid data');
20636 }
20637
20638 inner$3(datasetModel).sourceFormat = sourceFormat;
20639}
20640
20641/**
20642 * [Scenarios]:

Callers 1

Calls 4

isTypedArrayFunction · 0.70
isArrayFunction · 0.70
isObject$1Function · 0.70
isArrayLikeFunction · 0.70

Tested by

no test coverage detected