1 line
15 KiB
JSON
1 line
15 KiB
JSON
{"ast":null,"code":"/*\r\n* Licensed to the Apache Software Foundation (ASF) under one\r\n* or more contributor license agreements. See the NOTICE file\r\n* distributed with this work for additional information\r\n* regarding copyright ownership. The ASF licenses this file\r\n* to you under the Apache License, Version 2.0 (the\r\n* \"License\"); you may not use this file except in compliance\r\n* with the License. You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing,\r\n* software distributed under the License is distributed on an\r\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\n* KIND, either express or implied. See the License for the\r\n* specific language governing permissions and limitations\r\n* under the License.\r\n*/\n\n/**\r\n * AUTO-GENERATED FILE. DO NOT MODIFY.\r\n */\n\n/*\r\n* Licensed to the Apache Software Foundation (ASF) under one\r\n* or more contributor license agreements. See the NOTICE file\r\n* distributed with this work for additional information\r\n* regarding copyright ownership. The ASF licenses this file\r\n* to you under the Apache License, Version 2.0 (the\r\n* \"License\"); you may not use this file except in compliance\r\n* with the License. You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing,\r\n* software distributed under the License is distributed on an\r\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\n* KIND, either express or implied. See the License for the\r\n* specific language governing permissions and limitations\r\n* under the License.\r\n*/\nimport { createHashMap, each } from 'zrender/lib/core/util.js';\nimport { addSafe } from '../util/number.js'; // (1) [Caution]: the logic is correct based on the premises:\n// data processing stage is blocked in stream.\n// See <module:echarts/stream/Scheduler#performDataProcessorTasks>\n// (2) Only register once when import repeatly.\n// Should be executed after series filtered and before stack calculation.\n\nexport default function dataStack(ecModel) {\n var stackInfoMap = createHashMap();\n ecModel.eachSeries(function (seriesModel) {\n var stack = seriesModel.get('stack'); // Compatibal: when `stack` is set as '', do not stack.\n\n if (stack) {\n var stackInfoList = stackInfoMap.get(stack) || stackInfoMap.set(stack, []);\n var data = seriesModel.getData();\n var stackInfo = {\n // Used for calculate axis extent automatically.\n // TODO: Type getCalculationInfo return more specific type?\n stackResultDimension: data.getCalculationInfo('stackResultDimension'),\n stackedOverDimension: data.getCalculationInfo('stackedOverDimension'),\n stackedDimension: data.getCalculationInfo('stackedDimension'),\n stackedByDimension: data.getCalculationInfo('stackedByDimension'),\n isStackedByIndex: data.getCalculationInfo('isStackedByIndex'),\n data: data,\n seriesModel: seriesModel\n }; // If stacked on axis that do not support data stack.\n\n if (!stackInfo.stackedDimension || !(stackInfo.isStackedByIndex || stackInfo.stackedByDimension)) {\n return;\n }\n\n stackInfoList.length && data.setCalculationInfo('stackedOnSeries', stackInfoList[stackInfoList.length - 1].seriesModel);\n stackInfoList.push(stackInfo);\n }\n });\n stackInfoMap.each(calculateStack);\n}\n\nfunction calculateStack(stackInfoList) {\n each(stackInfoList, function (targetStackInfo, idxInStack) {\n var resultVal = [];\n var resultNaN = [NaN, NaN];\n var dims = [targetStackInfo.stackResultDimension, targetStackInfo.stackedOverDimension];\n var targetData = targetStackInfo.data;\n var isStackedByIndex = targetStackInfo.isStackedByIndex; // Should not write on raw data, because stack series model list changes\n // depending on legend selection.\n\n targetData.modify(dims, function (v0, v1, dataIndex) {\n var sum = targetData.get(targetStackInfo.stackedDimension, dataIndex); // Consider `connectNulls` of line area, if value is NaN, stackedOver\n // should also be NaN, to draw a appropriate belt area.\n\n if (isNaN(sum)) {\n return resultNaN;\n }\n\n var byValue;\n var stackedDataRawIndex;\n\n if (isStackedByIndex) {\n stackedDataRawIndex = targetData.getRawIndex(dataIndex);\n } else {\n byValue = targetData.get(targetStackInfo.stackedByDimension, dataIndex);\n } // If stackOver is NaN, chart view will render point on value start.\n\n\n var stackedOver = NaN;\n\n for (var j = idxInStack - 1; j >= 0; j--) {\n var stackInfo = stackInfoList[j]; // Has been optimized by inverted indices on `stackedByDimension`.\n\n if (!isStackedByIndex) {\n stackedDataRawIndex = stackInfo.data.rawIndexOf(stackInfo.stackedByDimension, byValue);\n }\n\n if (stackedDataRawIndex >= 0) {\n var val = stackInfo.data.getByRawIndex(stackInfo.stackResultDimension, stackedDataRawIndex); // Considering positive stack, negative stack and empty data\n\n if (sum >= 0 && val > 0 || // Positive stack\n sum <= 0 && val < 0 // Negative stack\n ) {\n // The sum should be as less as possible to be effected\n // by floating arithmetic problem. A wrong result probably\n // filtered incorrectly by axis min/max.\n sum = addSafe(sum, val);\n stackedOver = val;\n break;\n }\n }\n }\n\n resultVal[0] = sum;\n resultVal[1] = stackedOver;\n return resultVal;\n });\n });\n}","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src/qingge-Market/qingge-vue/node_modules/echarts/lib/processor/dataStack.js"],"names":["createHashMap","each","addSafe","dataStack","ecModel","stackInfoMap","eachSeries","seriesModel","stack","get","stackInfoList","set","data","getData","stackInfo","stackResultDimension","getCalculationInfo","stackedOverDimension","stackedDimension","stackedByDimension","isStackedByIndex","length","setCalculationInfo","push","calculateStack","targetStackInfo","idxInStack","resultVal","resultNaN","NaN","dims","targetData","modify","v0","v1","dataIndex","sum","isNaN","byValue","stackedDataRawIndex","getRawIndex","stackedOver","j","rawIndexOf","val","getByRawIndex"],"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,IAAxB,QAAoC,0BAApC;AACA,SAASC,OAAT,QAAwB,mBAAxB,C,CAA6C;AAC7C;AACA;AACA;AACA;;AAEA,eAAe,SAASC,SAAT,CAAmBC,OAAnB,EAA4B;AACzC,MAAIC,YAAY,GAAGL,aAAa,EAAhC;AACAI,EAAAA,OAAO,CAACE,UAAR,CAAmB,UAAU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SAAS,CAACK,kBAApC,EAAwDmB,OAAxD,CAAtB;AACD;;AAED,YAAIC,mBAAmB,IAAI,CAA3B,EAA8B;AAC5B,cAAIK,GAAG,GAAG9B,SAAS,CAACF,IAAV,CAAeiC,aAAf,CAA6B/B,SAAS,CAACC,oBAAvC,EAA6DwB,mBAA7D,CAAV,CAD4B,CACiE;;AAE7F,cAAIH,GAAG,IAAI,CAAP,IAAYQ,GAAG,GAAG,CAAlB,IAAuB;AAC3BR,UAAAA,GAAG,IAAI,CAAP,IAAYQ,GAAG,GAAG,CADlB,CACoB;AADpB,YAEE;AACE;AACA;AACA;AACAR,YAAAA,GAAG,GAAGlC,OAAO,CAACkC,GAAD,EAAMQ,GAAN,CAAb;AACAH,YAAAA,WAAW,GAAGG,GAAd;AACA;AACD;AACJ;AACF;;AAEDjB,MAAAA,SAAS,CAAC,CAAD,CAAT,GAAeS,GAAf;AACAT,MAAAA,SAAS,CAAC,CAAD,CAAT,GAAec,WAAf;AACA,aAAOd,SAAP;AACD,KA9CD;AA+CD,GAvDG,CAAJ;AAwDD","sourcesContent":["\r\n/*\r\n* Licensed to the Apache Software Foundation (ASF) under one\r\n* or more contributor license agreements. See the NOTICE file\r\n* distributed with this work for additional information\r\n* regarding copyright ownership. The ASF licenses this file\r\n* to you under the Apache License, Version 2.0 (the\r\n* \"License\"); you may not use this file except in compliance\r\n* with the License. You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing,\r\n* software distributed under the License is distributed on an\r\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\n* KIND, either express or implied. See the License for the\r\n* specific language governing permissions and limitations\r\n* under the License.\r\n*/\r\n\r\n\r\n/**\r\n * AUTO-GENERATED FILE. DO NOT MODIFY.\r\n */\r\n\r\n/*\r\n* Licensed to the Apache Software Foundation (ASF) under one\r\n* or more contributor license agreements. See the NOTICE file\r\n* distributed with this work for additional information\r\n* regarding copyright ownership. The ASF licenses this file\r\n* to you under the Apache License, Version 2.0 (the\r\n* \"License\"); you may not use this file except in compliance\r\n* with the License. You may obtain a copy of the License at\r\n*\r\n* http://www.apache.org/licenses/LICENSE-2.0\r\n*\r\n* Unless required by applicable law or agreed to in writing,\r\n* software distributed under the License is distributed on an\r\n* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\n* KIND, either express or implied. See the License for the\r\n* specific language governing permissions and limitations\r\n* under the License.\r\n*/\r\nimport { createHashMap, each } from 'zrender/lib/core/util.js';\r\nimport { addSafe } from '../util/number.js'; // (1) [Caution]: the logic is correct based on the premises:\r\n// data processing stage is blocked in stream.\r\n// See <module:echarts/stream/Scheduler#performDataProcessorTasks>\r\n// (2) Only register once when import repeatly.\r\n// Should be executed after series filtered and before stack calculation.\r\n\r\nexport default function dataStack(ecModel) {\r\n var stackInfoMap = createHashMap();\r\n ecModel.eachSeries(function (seriesModel) {\r\n var stack = seriesModel.get('stack'); // Compatibal: when `stack` is set as '', do not stack.\r\n\r\n if (stack) {\r\n var stackInfoList = stackInfoMap.get(stack) || stackInfoMap.set(stack, []);\r\n var data = seriesModel.getData();\r\n var stackInfo = {\r\n // Used for calculate axis extent automatically.\r\n // TODO: Type getCalculationInfo return more specific type?\r\n stackResultDimension: data.getCalculationInfo('stackResultDimension'),\r\n stackedOverDimension: data.getCalculationInfo('stackedOverDimension'),\r\n stackedDimension: data.getCalculationInfo('stackedDimension'),\r\n stackedByDimension: data.getCalculationInfo('stackedByDimension'),\r\n isStackedByIndex: data.getCalculationInfo('isStackedByIndex'),\r\n data: data,\r\n seriesModel: seriesModel\r\n }; // If stacked on axis that do not support data stack.\r\n\r\n if (!stackInfo.stackedDimension || !(stackInfo.isStackedByIndex || stackInfo.stackedByDimension)) {\r\n return;\r\n }\r\n\r\n stackInfoList.length && data.setCalculationInfo('stackedOnSeries', stackInfoList[stackInfoList.length - 1].seriesModel);\r\n stackInfoList.push(stackInfo);\r\n }\r\n });\r\n stackInfoMap.each(calculateStack);\r\n}\r\n\r\nfunction calculateStack(stackInfoList) {\r\n each(stackInfoList, function (targetStackInfo, idxInStack) {\r\n var resultVal = [];\r\n var resultNaN = [NaN, NaN];\r\n var dims = [targetStackInfo.stackResultDimension, targetStackInfo.stackedOverDimension];\r\n var targetData = targetStackInfo.data;\r\n var isStackedByIndex = targetStackInfo.isStackedByIndex; // Should not write on raw data, because stack series model list changes\r\n // depending on legend selection.\r\n\r\n targetData.modify(dims, function (v0, v1, dataIndex) {\r\n var sum = targetData.get(targetStackInfo.stackedDimension, dataIndex); // Consider `connectNulls` of line area, if value is NaN, stackedOver\r\n // should also be NaN, to draw a appropriate belt area.\r\n\r\n if (isNaN(sum)) {\r\n return resultNaN;\r\n }\r\n\r\n var byValue;\r\n var stackedDataRawIndex;\r\n\r\n if (isStackedByIndex) {\r\n stackedDataRawIndex = targetData.getRawIndex(dataIndex);\r\n } else {\r\n byValue = targetData.get(targetStackInfo.stackedByDimension, dataIndex);\r\n } // If stackOver is NaN, chart view will render point on value start.\r\n\r\n\r\n var stackedOver = NaN;\r\n\r\n for (var j = idxInStack - 1; j >= 0; j--) {\r\n var stackInfo = stackInfoList[j]; // Has been optimized by inverted indices on `stackedByDimension`.\r\n\r\n if (!isStackedByIndex) {\r\n stackedDataRawIndex = stackInfo.data.rawIndexOf(stackInfo.stackedByDimension, byValue);\r\n }\r\n\r\n if (stackedDataRawIndex >= 0) {\r\n var val = stackInfo.data.getByRawIndex(stackInfo.stackResultDimension, stackedDataRawIndex); // Considering positive stack, negative stack and empty data\r\n\r\n if (sum >= 0 && val > 0 || // Positive stack\r\n sum <= 0 && val < 0 // Negative stack\r\n ) {\r\n // The sum should be as less as possible to be effected\r\n // by floating arithmetic problem. A wrong result probably\r\n // filtered incorrectly by axis min/max.\r\n sum = addSafe(sum, val);\r\n stackedOver = val;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n resultVal[0] = sum;\r\n resultVal[1] = stackedOver;\r\n return resultVal;\r\n });\r\n });\r\n}"]},"metadata":{},"sourceType":"module"} |