1 line
24 KiB
JSON
1 line
24 KiB
JSON
{"ast":null,"code":"import \"core-js/modules/es.function.name.js\";\nimport \"core-js/modules/es.regexp.exec.js\";\nimport \"core-js/modules/es.string.replace.js\";\nimport \"core-js/modules/es.array.join.js\";\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { createHashMap, isObject, retrieve2 } from 'zrender/lib/core/util.js';\nimport { makeInner } from '../../util/model.js';\nimport { shouldRetrieveDataByName } from '../Source.js';\nvar inner = makeInner();\nvar dimTypeShort = {\n float: 'f',\n int: 'i',\n ordinal: 'o',\n number: 'n',\n time: 't'\n};\n/**\n * Represents the dimension requirement of a series.\n *\n * NOTICE:\n * When there are too many dimensions in dataset and many series, only the used dimensions\n * (i.e., used by coord sys and declared in `series.encode`) are add to `dimensionDefineList`.\n * But users may query data by other unused dimension names.\n * In this case, users can only query data if and only if they have defined dimension names\n * via ec option, so we provide `getDimensionIndexFromSource`, which only query them from\n * `source` dimensions.\n */\n\nvar SeriesDataSchema =\n/** @class */\nfunction () {\n function SeriesDataSchema(opt) {\n this.dimensions = opt.dimensions;\n this._dimOmitted = opt.dimensionOmitted;\n this.source = opt.source;\n this._fullDimCount = opt.fullDimensionCount;\n\n this._updateDimOmitted(opt.dimensionOmitted);\n }\n\n SeriesDataSchema.prototype.isDimensionOmitted = function () {\n return this._dimOmitted;\n };\n\n SeriesDataSchema.prototype._updateDimOmitted = function (dimensionOmitted) {\n this._dimOmitted = dimensionOmitted;\n\n if (!dimensionOmitted) {\n return;\n }\n\n if (!this._dimNameMap) {\n this._dimNameMap = ensureSourceDimNameMap(this.source);\n }\n };\n /**\n * @caution Can only be used when `dimensionOmitted: true`.\n *\n * Get index by user defined dimension name (i.e., not internal generate name).\n * That is, get index from `dimensionsDefine`.\n * If no `dimensionsDefine`, or no name get, return -1.\n */\n\n\n SeriesDataSchema.prototype.getSourceDimensionIndex = function (dimName) {\n return retrieve2(this._dimNameMap.get(dimName), -1);\n };\n /**\n * @caution Can only be used when `dimensionOmitted: true`.\n *\n * Notice: may return `null`/`undefined` if user not specify dimension names.\n */\n\n\n SeriesDataSchema.prototype.getSourceDimension = function (dimIndex) {\n var dimensionsDefine = this.source.dimensionsDefine;\n\n if (dimensionsDefine) {\n return dimensionsDefine[dimIndex];\n }\n };\n\n SeriesDataSchema.prototype.makeStoreSchema = function () {\n var dimCount = this._fullDimCount;\n var willRetrieveDataByName = shouldRetrieveDataByName(this.source);\n var makeHashStrict = !shouldOmitUnusedDimensions(dimCount); // If source don't have dimensions or series don't omit unsed dimensions.\n // Generate from seriesDimList directly\n\n var dimHash = '';\n var dims = [];\n\n for (var fullDimIdx = 0, seriesDimIdx = 0; fullDimIdx < dimCount; fullDimIdx++) {\n var property = void 0;\n var type = void 0;\n var ordinalMeta = void 0;\n var seriesDimDef = this.dimensions[seriesDimIdx]; // The list has been sorted by `storeDimIndex` asc.\n\n if (seriesDimDef && seriesDimDef.storeDimIndex === fullDimIdx) {\n property = willRetrieveDataByName ? seriesDimDef.name : null;\n type = seriesDimDef.type;\n ordinalMeta = seriesDimDef.ordinalMeta;\n seriesDimIdx++;\n } else {\n var sourceDimDef = this.getSourceDimension(fullDimIdx);\n\n if (sourceDimDef) {\n property = willRetrieveDataByName ? sourceDimDef.name : null;\n type = sourceDimDef.type;\n }\n }\n\n dims.push({\n property: property,\n type: type,\n ordinalMeta: ordinalMeta\n }); // If retrieving data by index,\n // use <index, type, ordinalMeta> to determine whether data can be shared.\n // (Because in this case there might be no dimension name defined in dataset, but indices always exists).\n // (Indices are always 0, 1, 2, ..., so we can ignore them to shorten the hash).\n // Otherwise if retrieving data by property name (like `data: [{aa: 123, bb: 765}, ...]`),\n // use <property, type, ordinalMeta> in hash.\n\n if (willRetrieveDataByName && property != null // For data stack, we have make sure each series has its own dim on this store.\n // So we do not add property to hash to make sure they can share this store.\n && (!seriesDimDef || !seriesDimDef.isCalculationCoord)) {\n dimHash += makeHashStrict // Use escape character '`' in case that property name contains '$'.\n ? property.replace(/\\`/g, '`1').replace(/\\$/g, '`2') // For better performance, when there are large dimensions, tolerant this defects that hardly meet.\n : property;\n }\n\n dimHash += '$';\n dimHash += dimTypeShort[type] || 'f';\n\n if (ordinalMeta) {\n dimHash += ordinalMeta.uid;\n }\n\n dimHash += '$';\n } // Source from endpoint(usually series) will be read differently\n // when seriesLayoutBy or startIndex(which is affected by sourceHeader) are different.\n // So we use this three props as key.\n\n\n var source = this.source;\n var hash = [source.seriesLayoutBy, source.startIndex, dimHash].join('$$');\n return {\n dimensions: dims,\n hash: hash\n };\n };\n\n SeriesDataSchema.prototype.makeOutputDimensionNames = function () {\n var result = [];\n\n for (var fullDimIdx = 0, seriesDimIdx = 0; fullDimIdx < this._fullDimCount; fullDimIdx++) {\n var name_1 = void 0;\n var seriesDimDef = this.dimensions[seriesDimIdx]; // The list has been sorted by `storeDimIndex` asc.\n\n if (seriesDimDef && seriesDimDef.storeDimIndex === fullDimIdx) {\n if (!seriesDimDef.isCalculationCoord) {\n name_1 = seriesDimDef.name;\n }\n\n seriesDimIdx++;\n } else {\n var sourceDimDef = this.getSourceDimension(fullDimIdx);\n\n if (sourceDimDef) {\n name_1 = sourceDimDef.name;\n }\n }\n\n result.push(name_1);\n }\n\n return result;\n };\n\n SeriesDataSchema.prototype.appendCalculationDimension = function (dimDef) {\n this.dimensions.push(dimDef);\n dimDef.isCalculationCoord = true;\n this._fullDimCount++; // If append dimension on a data store, consider the store\n // might be shared by different series, series dimensions not\n // really map to store dimensions.\n\n this._updateDimOmitted(true);\n };\n\n return SeriesDataSchema;\n}();\n\nexport { SeriesDataSchema };\nexport function isSeriesDataSchema(schema) {\n return schema instanceof SeriesDataSchema;\n}\nexport function createDimNameMap(dimsDef) {\n var dataDimNameMap = createHashMap();\n\n for (var i = 0; i < (dimsDef || []).length; i++) {\n var dimDefItemRaw = dimsDef[i];\n var userDimName = isObject(dimDefItemRaw) ? dimDefItemRaw.name : dimDefItemRaw;\n\n if (userDimName != null && dataDimNameMap.get(userDimName) == null) {\n dataDimNameMap.set(userDimName, i);\n }\n }\n\n return dataDimNameMap;\n}\nexport function ensureSourceDimNameMap(source) {\n var innerSource = inner(source);\n return innerSource.dimNameMap || (innerSource.dimNameMap = createDimNameMap(source.dimensionsDefine));\n}\nexport function shouldOmitUnusedDimensions(dimCount) {\n return dimCount > 30;\n}","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src啊/ElectronicMallVue/node_modules/echarts/lib/data/helper/SeriesDataSchema.js"],"names":["createHashMap","isObject","retrieve2","makeInner","shouldRetrieveDataByName","inner","dimTypeShort","float","int","ordinal","number","time","SeriesDataSchema","opt","dimensions","_dimOmitted","dimensionOmitted","source","_fullDimCount","fullDimensionCount","_updateDimOmitted","prototype","isDimensionOmitted","_dimNameMap","ensureSourceDimNameMap","getSourceDimensionIndex","dimName","get","getSourceDimension","dimIndex","dimensionsDefine","makeStoreSchema","dimCount","willRetrieveDataByName","makeHashStrict","shouldOmitUnusedDimensions","dimHash","dims","fullDimIdx","seriesDimIdx","property","type","ordinalMeta","seriesDimDef","storeDimIndex","name","sourceDimDef","push","isCalculationCoord","replace","uid","hash","seriesLayoutBy","startIndex","join","makeOutputDimensionNames","result","name_1","appendCalculationDimension","dimDef","isSeriesDataSchema","schema","createDimNameMap","dimsDef","dataDimNameMap","i","length","dimDefItemRaw","userDimName","set","innerSource","dimNameMap"],"mappings":";;;;;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,QAAxB,EAAkCC,SAAlC,QAAmD,0BAAnD;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,wBAAT,QAAyC,cAAzC;AACA,IAAIC,KAAK,GAAGF,SAAS,EAArB;AACA,IAAIG,YAAY,GAAG;AACjBC,EAAAA,KAAK,EAAE,GADU;AAEjBC,EAAAA,GAAG,EAAE,GAFY;AAGjBC,EAAAA,OAAO,EAAE,GAHQ;AAIjBC,EAAAA,MAAM,EAAE,GAJS;AAKjBC,EAAAA,IAAI,EAAE;AALW,CAAnB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,IAAIC,gBAAgB;AACpB;AACA,YAAY;AACV,WAASA,gBAAT,CAA0BC,GAA1B,EAA+B;AAC7B,SAAKC,UAAL,GAAkBD,GAAG,CAACC,UAAtB;AACA,SAAKC,WAAL,GAAmBF,GAAG,CAACG,gBAAvB;AACA,SAAKC,MAAL,GAAcJ,GAAG,CAACI,MAAlB;AACA,SAAKC,aAAL,GAAqBL,G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C;AAC7C,MAAIqD,WAAW,GAAGjE,KAAK,CAACY,MAAD,CAAvB;AACA,SAAOqD,WAAW,CAACC,UAAZ,KAA2BD,WAAW,CAACC,UAAZ,GAAyBT,gBAAgB,CAAC7C,MAAM,CAACa,gBAAR,CAApE,CAAP;AACD;AACD,OAAO,SAASK,0BAAT,CAAoCH,QAApC,EAA8C;AACnD,SAAOA,QAAQ,GAAG,EAAlB;AACD","sourcesContent":["\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\n\n\n/**\n * AUTO-GENERATED FILE. DO NOT MODIFY.\n */\n\n/*\n* Licensed to the Apache Software Foundation (ASF) under one\n* or more contributor license agreements. See the NOTICE file\n* distributed with this work for additional information\n* regarding copyright ownership. The ASF licenses this file\n* to you under the Apache License, Version 2.0 (the\n* \"License\"); you may not use this file except in compliance\n* with the License. You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing,\n* software distributed under the License is distributed on an\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n* KIND, either express or implied. See the License for the\n* specific language governing permissions and limitations\n* under the License.\n*/\nimport { createHashMap, isObject, retrieve2 } from 'zrender/lib/core/util.js';\nimport { makeInner } from '../../util/model.js';\nimport { shouldRetrieveDataByName } from '../Source.js';\nvar inner = makeInner();\nvar dimTypeShort = {\n float: 'f',\n int: 'i',\n ordinal: 'o',\n number: 'n',\n time: 't'\n};\n/**\n * Represents the dimension requirement of a series.\n *\n * NOTICE:\n * When there are too many dimensions in dataset and many series, only the used dimensions\n * (i.e., used by coord sys and declared in `series.encode`) are add to `dimensionDefineList`.\n * But users may query data by other unused dimension names.\n * In this case, users can only query data if and only if they have defined dimension names\n * via ec option, so we provide `getDimensionIndexFromSource`, which only query them from\n * `source` dimensions.\n */\n\nvar SeriesDataSchema =\n/** @class */\nfunction () {\n function SeriesDataSchema(opt) {\n this.dimensions = opt.dimensions;\n this._dimOmitted = opt.dimensionOmitted;\n this.source = opt.source;\n this._fullDimCount = opt.fullDimensionCount;\n\n this._updateDimOmitted(opt.dimensionOmitted);\n }\n\n SeriesDataSchema.prototype.isDimensionOmitted = function () {\n return this._dimOmitted;\n };\n\n SeriesDataSchema.prototype._updateDimOmitted = function (dimensionOmitted) {\n this._dimOmitted = dimensionOmitted;\n\n if (!dimensionOmitted) {\n return;\n }\n\n if (!this._dimNameMap) {\n this._dimNameMap = ensureSourceDimNameMap(this.source);\n }\n };\n /**\n * @caution Can only be used when `dimensionOmitted: true`.\n *\n * Get index by user defined dimension name (i.e., not internal generate name).\n * That is, get index from `dimensionsDefine`.\n * If no `dimensionsDefine`, or no name get, return -1.\n */\n\n\n SeriesDataSchema.prototype.getSourceDimensionIndex = function (dimName) {\n return retrieve2(this._dimNameMap.get(dimName), -1);\n };\n /**\n * @caution Can only be used when `dimensionOmitted: true`.\n *\n * Notice: may return `null`/`undefined` if user not specify dimension names.\n */\n\n\n SeriesDataSchema.prototype.getSourceDimension = function (dimIndex) {\n var dimensionsDefine = this.source.dimensionsDefine;\n\n if (dimensionsDefine) {\n return dimensionsDefine[dimIndex];\n }\n };\n\n SeriesDataSchema.prototype.makeStoreSchema = function () {\n var dimCount = this._fullDimCount;\n var willRetrieveDataByName = shouldRetrieveDataByName(this.source);\n var makeHashStrict = !shouldOmitUnusedDimensions(dimCount); // If source don't have dimensions or series don't omit unsed dimensions.\n // Generate from seriesDimList directly\n\n var dimHash = '';\n var dims = [];\n\n for (var fullDimIdx = 0, seriesDimIdx = 0; fullDimIdx < dimCount; fullDimIdx++) {\n var property = void 0;\n var type = void 0;\n var ordinalMeta = void 0;\n var seriesDimDef = this.dimensions[seriesDimIdx]; // The list has been sorted by `storeDimIndex` asc.\n\n if (seriesDimDef && seriesDimDef.storeDimIndex === fullDimIdx) {\n property = willRetrieveDataByName ? seriesDimDef.name : null;\n type = seriesDimDef.type;\n ordinalMeta = seriesDimDef.ordinalMeta;\n seriesDimIdx++;\n } else {\n var sourceDimDef = this.getSourceDimension(fullDimIdx);\n\n if (sourceDimDef) {\n property = willRetrieveDataByName ? sourceDimDef.name : null;\n type = sourceDimDef.type;\n }\n }\n\n dims.push({\n property: property,\n type: type,\n ordinalMeta: ordinalMeta\n }); // If retrieving data by index,\n // use <index, type, ordinalMeta> to determine whether data can be shared.\n // (Because in this case there might be no dimension name defined in dataset, but indices always exists).\n // (Indices are always 0, 1, 2, ..., so we can ignore them to shorten the hash).\n // Otherwise if retrieving data by property name (like `data: [{aa: 123, bb: 765}, ...]`),\n // use <property, type, ordinalMeta> in hash.\n\n if (willRetrieveDataByName && property != null // For data stack, we have make sure each series has its own dim on this store.\n // So we do not add property to hash to make sure they can share this store.\n && (!seriesDimDef || !seriesDimDef.isCalculationCoord)) {\n dimHash += makeHashStrict // Use escape character '`' in case that property name contains '$'.\n ? property.replace(/\\`/g, '`1').replace(/\\$/g, '`2') // For better performance, when there are large dimensions, tolerant this defects that hardly meet.\n : property;\n }\n\n dimHash += '$';\n dimHash += dimTypeShort[type] || 'f';\n\n if (ordinalMeta) {\n dimHash += ordinalMeta.uid;\n }\n\n dimHash += '$';\n } // Source from endpoint(usually series) will be read differently\n // when seriesLayoutBy or startIndex(which is affected by sourceHeader) are different.\n // So we use this three props as key.\n\n\n var source = this.source;\n var hash = [source.seriesLayoutBy, source.startIndex, dimHash].join('$$');\n return {\n dimensions: dims,\n hash: hash\n };\n };\n\n SeriesDataSchema.prototype.makeOutputDimensionNames = function () {\n var result = [];\n\n for (var fullDimIdx = 0, seriesDimIdx = 0; fullDimIdx < this._fullDimCount; fullDimIdx++) {\n var name_1 = void 0;\n var seriesDimDef = this.dimensions[seriesDimIdx]; // The list has been sorted by `storeDimIndex` asc.\n\n if (seriesDimDef && seriesDimDef.storeDimIndex === fullDimIdx) {\n if (!seriesDimDef.isCalculationCoord) {\n name_1 = seriesDimDef.name;\n }\n\n seriesDimIdx++;\n } else {\n var sourceDimDef = this.getSourceDimension(fullDimIdx);\n\n if (sourceDimDef) {\n name_1 = sourceDimDef.name;\n }\n }\n\n result.push(name_1);\n }\n\n return result;\n };\n\n SeriesDataSchema.prototype.appendCalculationDimension = function (dimDef) {\n this.dimensions.push(dimDef);\n dimDef.isCalculationCoord = true;\n this._fullDimCount++; // If append dimension on a data store, consider the store\n // might be shared by different series, series dimensions not\n // really map to store dimensions.\n\n this._updateDimOmitted(true);\n };\n\n return SeriesDataSchema;\n}();\n\nexport { SeriesDataSchema };\nexport function isSeriesDataSchema(schema) {\n return schema instanceof SeriesDataSchema;\n}\nexport function createDimNameMap(dimsDef) {\n var dataDimNameMap = createHashMap();\n\n for (var i = 0; i < (dimsDef || []).length; i++) {\n var dimDefItemRaw = dimsDef[i];\n var userDimName = isObject(dimDefItemRaw) ? dimDefItemRaw.name : dimDefItemRaw;\n\n if (userDimName != null && dataDimNameMap.get(userDimName) == null) {\n dataDimNameMap.set(userDimName, i);\n }\n }\n\n return dataDimNameMap;\n}\nexport function ensureSourceDimNameMap(source) {\n var innerSource = inner(source);\n return innerSource.dimNameMap || (innerSource.dimNameMap = createDimNameMap(source.dimensionsDefine));\n}\nexport function shouldOmitUnusedDimensions(dimCount) {\n return dimCount > 30;\n}"]},"metadata":{},"sourceType":"module"} |