1 line
21 KiB
JSON
1 line
21 KiB
JSON
{"ast":null,"code":"/*\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 { __extends } from \"tslib\";\nimport * as zrUtil from 'zrender/lib/core/util.js';\nimport ChartView from '../../view/Chart.js';\nimport SunburstPiece from './SunburstPiece.js';\nimport DataDiffer from '../../data/DataDiffer.js';\nimport { ROOT_TO_NODE_ACTION } from './sunburstAction.js';\nimport { windowOpen } from '../../util/format.js';\n\nvar SunburstView =\n/** @class */\nfunction (_super) {\n __extends(SunburstView, _super);\n\n function SunburstView() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n\n _this.type = SunburstView.type;\n return _this;\n }\n\n SunburstView.prototype.render = function (seriesModel, ecModel, api, // @ts-ignore\n payload) {\n var self = this;\n this.seriesModel = seriesModel;\n this.api = api;\n this.ecModel = ecModel;\n var data = seriesModel.getData();\n var virtualRoot = data.tree.root;\n var newRoot = seriesModel.getViewRoot();\n var group = this.group;\n var renderLabelForZeroData = seriesModel.get('renderLabelForZeroData');\n var newChildren = [];\n newRoot.eachNode(function (node) {\n newChildren.push(node);\n });\n var oldChildren = this._oldChildren || [];\n dualTravel(newChildren, oldChildren);\n renderRollUp(virtualRoot, newRoot);\n\n this._initEvents();\n\n this._oldChildren = newChildren;\n\n function dualTravel(newChildren, oldChildren) {\n if (newChildren.length === 0 && oldChildren.length === 0) {\n return;\n }\n\n new DataDiffer(oldChildren, newChildren, getKey, getKey).add(processNode).update(processNode).remove(zrUtil.curry(processNode, null)).execute();\n\n function getKey(node) {\n return node.getId();\n }\n\n function processNode(newIdx, oldIdx) {\n var newNode = newIdx == null ? null : newChildren[newIdx];\n var oldNode = oldIdx == null ? null : oldChildren[oldIdx];\n doRenderNode(newNode, oldNode);\n }\n }\n\n function doRenderNode(newNode, oldNode) {\n if (!renderLabelForZeroData && newNode && !newNode.getValue()) {\n // Not render data with value 0\n newNode = null;\n }\n\n if (newNode !== virtualRoot && oldNode !== virtualRoot) {\n if (oldNode && oldNode.piece) {\n if (newNode) {\n // Update\n oldNode.piece.updateData(false, newNode, seriesModel, ecModel, api); // For tooltip\n\n data.setItemGraphicEl(newNode.dataIndex, oldNode.piece);\n } else {\n // Remove\n removeNode(oldNode);\n }\n } else if (newNode) {\n // Add\n var piece = new SunburstPiece(newNode, seriesModel, ecModel, api);\n group.add(piece); // For tooltip\n\n data.setItemGraphicEl(newNode.dataIndex, piece);\n }\n }\n }\n\n function removeNode(node) {\n if (!node) {\n return;\n }\n\n if (node.piece) {\n group.remove(node.piece);\n node.piece = null;\n }\n }\n\n function renderRollUp(virtualRoot, viewRoot) {\n if (viewRoot.depth > 0) {\n // Render\n if (self.virtualPiece) {\n // Update\n self.virtualPiece.updateData(false, virtualRoot, seriesModel, ecModel, api);\n } else {\n // Add\n self.virtualPiece = new SunburstPiece(virtualRoot, seriesModel, ecModel, api);\n group.add(self.virtualPiece);\n } // TODO event scope\n\n\n viewRoot.piece.off('click');\n self.virtualPiece.on('click', function (e) {\n self._rootToNode(viewRoot.parentNode);\n });\n } else if (self.virtualPiece) {\n // Remove\n group.remove(self.virtualPiece);\n self.virtualPiece = null;\n }\n }\n };\n /**\n * @private\n */\n\n\n SunburstView.prototype._initEvents = function () {\n var _this = this;\n\n this.group.off('click');\n this.group.on('click', function (e) {\n var targetFound = false;\n\n var viewRoot = _this.seriesModel.getViewRoot();\n\n viewRoot.eachNode(function (node) {\n if (!targetFound && node.piece && node.piece === e.target) {\n var nodeClick = node.getModel().get('nodeClick');\n\n if (nodeClick === 'rootToNode') {\n _this._rootToNode(node);\n } else if (nodeClick === 'link') {\n var itemModel = node.getModel();\n var link = itemModel.get('link');\n\n if (link) {\n var linkTarget = itemModel.get('target', true) || '_blank';\n windowOpen(link, linkTarget);\n }\n }\n\n targetFound = true;\n }\n });\n });\n };\n /**\n * @private\n */\n\n\n SunburstView.prototype._rootToNode = function (node) {\n if (node !== this.seriesModel.getViewRoot()) {\n this.api.dispatchAction({\n type: ROOT_TO_NODE_ACTION,\n from: this.uid,\n seriesId: this.seriesModel.id,\n targetNode: node\n });\n }\n };\n /**\n * @implement\n */\n\n\n SunburstView.prototype.containPoint = function (point, seriesModel) {\n var treeRoot = seriesModel.getData();\n var itemLayout = treeRoot.getItemLayout(0);\n\n if (itemLayout) {\n var dx = point[0] - itemLayout.cx;\n var dy = point[1] - itemLayout.cy;\n var radius = Math.sqrt(dx * dx + dy * dy);\n return radius <= itemLayout.r && radius >= itemLayout.r0;\n }\n };\n\n SunburstView.type = 'sunburst';\n return SunburstView;\n}(ChartView);\n\nexport default SunburstView;","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src啊/ElectronicMallVue/node_modules/echarts/lib/chart/sunburst/SunburstView.js"],"names":["__extends","zrUtil","ChartView","SunburstPiece","DataDiffer","ROOT_TO_NODE_ACTION","windowOpen","SunburstView","_super","_this","apply","arguments","type","prototype","render","seriesModel","ecModel","api","payload","self","data","getData","virtualRoot","tree","root","newRoot","getViewRoot","group","renderLabelForZeroData","get","newChildren","eachNode","node","push","oldChildren","_oldChildren","dualTravel","renderRollUp","_initEvents","length","getKey","add","processNode","update","remove","curry","execute","getId","newIdx","oldIdx","newNode","oldNode","doRenderNode","getValue","piece","updateData","setItemGraphicEl","dataIndex","removeNode","viewRoot","depth","virtualPiece","off","on","e","_rootToNode","parentNode","targetFound","target","nodeClick","getModel","itemModel","link","linkTarget","dispatchAction","from","uid","seriesId","id","targetNode","containPoint","point","treeRoot","itemLayout","getItemLayout","dx","cx","dy","cy","radius","Math","sqrt","r","r0"],"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,SAAT,QAA0B,OAA1B;AACA,OAAO,KAAKC,MAAZ,MAAwB,0BAAxB;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,aAAP,MAA0B,oBAA1B;AACA,OAAOC,UAAP,MAAuB,0BAAvB;AACA,SAASC,mBAAT,QAAoC,qBAApC;AACA,SAASC,UAAT,QAA2B,sBAA3B;;AAEA,IAAIC,YAAY;AAChB;AACA,UAAUC,MAAV,EAAkB;AAChBR,EAAAA,SAAS,CAACO,YAAD,EAAeC,MAAf,CAAT;;AAEA,WAASD,YAAT,GAAwB;AACtB,QAAIE,KAAK,GAAGD,MAAM,KAAK,IAAX,IAAmBA,MAAM,CAACE,KAAP,CAAa,IAAb,EAAmBC,SAAnB,CAAnB,IAAoD,IAAhE;;AAEAF,IAAAA,KAAK,CAACG,IAAN,GAAaL,YAAY,CAACK,IAA1B;AACA,WAAOH,KAAP;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KAxBD;AAyBD,GA7BD;AA8BA;AACF;AACA;;;AAGE5D,EAAAA,YAAY,CAACM,SAAb,CAAuBoD,WAAvB,GAAqC,UAAUjC,IAAV,EAAgB;AACnD,QAAIA,IAAI,KAAK,KAAKjB,WAAL,CAAiBW,WAAjB,EAAb,EAA6C;AAC3C,WAAKT,GAAL,CAASyD,cAAT,CAAwB;AACtB9D,QAAAA,IAAI,EAAEP,mBADgB;AAEtBsE,QAAAA,IAAI,EAAE,KAAKC,GAFW;AAGtBC,QAAAA,QAAQ,EAAE,KAAK9D,WAAL,CAAiB+D,EAHL;AAItBC,QAAAA,UAAU,EAAE/C;AAJU,OAAxB;AAMD;AACF,GATD;AAUA;AACF;AACA;;;AAGEzB,EAAAA,YAAY,CAACM,SAAb,CAAuBmE,YAAvB,GAAsC,UAAUC,KAAV,EAAiBlE,WAAjB,EAA8B;AAClE,QAAImE,QAAQ,GAAGnE,WAAW,CAACM,OAAZ,EAAf;AACA,QAAI8D,UAAU,GAAGD,QAAQ,CAACE,aAAT,CAAuB,CAAvB,CAAjB;;AAEA,QAAID,UAAJ,EAAgB;AACd,UAAIE,EAAE,GAAGJ,KAAK,CAAC,CAAD,CAAL,GAAWE,UAAU,CAACG,EAA/B;AACA,UAAIC,EAAE,GAAGN,KAAK,CAAC,CAAD,CAAL,GAAWE,UAAU,CAACK,EAA/B;AACA,UAAIC,MAAM,GAAGC,IAAI,CAACC,IAAL,CAAUN,EAAE,GAAGA,EAAL,GAAUE,EAAE,GAAGA,EAAzB,CAAb;AACA,aAAOE,MAAM,IAAIN,UAAU,CAACS,CAArB,IAA0BH,MAAM,IAAIN,UAAU,CAACU,EAAtD;AACD;AACF,GAVD;;AAYAtF,EAAAA,YAAY,CAACK,IAAb,GAAoB,UAApB;AACA,SAAOL,YAAP;AACD,CAtLD,CAsLEL,SAtLF,CAFA;;AA0LA,eAAeK,YAAf","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 { __extends } from \"tslib\";\nimport * as zrUtil from 'zrender/lib/core/util.js';\nimport ChartView from '../../view/Chart.js';\nimport SunburstPiece from './SunburstPiece.js';\nimport DataDiffer from '../../data/DataDiffer.js';\nimport { ROOT_TO_NODE_ACTION } from './sunburstAction.js';\nimport { windowOpen } from '../../util/format.js';\n\nvar SunburstView =\n/** @class */\nfunction (_super) {\n __extends(SunburstView, _super);\n\n function SunburstView() {\n var _this = _super !== null && _super.apply(this, arguments) || this;\n\n _this.type = SunburstView.type;\n return _this;\n }\n\n SunburstView.prototype.render = function (seriesModel, ecModel, api, // @ts-ignore\n payload) {\n var self = this;\n this.seriesModel = seriesModel;\n this.api = api;\n this.ecModel = ecModel;\n var data = seriesModel.getData();\n var virtualRoot = data.tree.root;\n var newRoot = seriesModel.getViewRoot();\n var group = this.group;\n var renderLabelForZeroData = seriesModel.get('renderLabelForZeroData');\n var newChildren = [];\n newRoot.eachNode(function (node) {\n newChildren.push(node);\n });\n var oldChildren = this._oldChildren || [];\n dualTravel(newChildren, oldChildren);\n renderRollUp(virtualRoot, newRoot);\n\n this._initEvents();\n\n this._oldChildren = newChildren;\n\n function dualTravel(newChildren, oldChildren) {\n if (newChildren.length === 0 && oldChildren.length === 0) {\n return;\n }\n\n new DataDiffer(oldChildren, newChildren, getKey, getKey).add(processNode).update(processNode).remove(zrUtil.curry(processNode, null)).execute();\n\n function getKey(node) {\n return node.getId();\n }\n\n function processNode(newIdx, oldIdx) {\n var newNode = newIdx == null ? null : newChildren[newIdx];\n var oldNode = oldIdx == null ? null : oldChildren[oldIdx];\n doRenderNode(newNode, oldNode);\n }\n }\n\n function doRenderNode(newNode, oldNode) {\n if (!renderLabelForZeroData && newNode && !newNode.getValue()) {\n // Not render data with value 0\n newNode = null;\n }\n\n if (newNode !== virtualRoot && oldNode !== virtualRoot) {\n if (oldNode && oldNode.piece) {\n if (newNode) {\n // Update\n oldNode.piece.updateData(false, newNode, seriesModel, ecModel, api); // For tooltip\n\n data.setItemGraphicEl(newNode.dataIndex, oldNode.piece);\n } else {\n // Remove\n removeNode(oldNode);\n }\n } else if (newNode) {\n // Add\n var piece = new SunburstPiece(newNode, seriesModel, ecModel, api);\n group.add(piece); // For tooltip\n\n data.setItemGraphicEl(newNode.dataIndex, piece);\n }\n }\n }\n\n function removeNode(node) {\n if (!node) {\n return;\n }\n\n if (node.piece) {\n group.remove(node.piece);\n node.piece = null;\n }\n }\n\n function renderRollUp(virtualRoot, viewRoot) {\n if (viewRoot.depth > 0) {\n // Render\n if (self.virtualPiece) {\n // Update\n self.virtualPiece.updateData(false, virtualRoot, seriesModel, ecModel, api);\n } else {\n // Add\n self.virtualPiece = new SunburstPiece(virtualRoot, seriesModel, ecModel, api);\n group.add(self.virtualPiece);\n } // TODO event scope\n\n\n viewRoot.piece.off('click');\n self.virtualPiece.on('click', function (e) {\n self._rootToNode(viewRoot.parentNode);\n });\n } else if (self.virtualPiece) {\n // Remove\n group.remove(self.virtualPiece);\n self.virtualPiece = null;\n }\n }\n };\n /**\n * @private\n */\n\n\n SunburstView.prototype._initEvents = function () {\n var _this = this;\n\n this.group.off('click');\n this.group.on('click', function (e) {\n var targetFound = false;\n\n var viewRoot = _this.seriesModel.getViewRoot();\n\n viewRoot.eachNode(function (node) {\n if (!targetFound && node.piece && node.piece === e.target) {\n var nodeClick = node.getModel().get('nodeClick');\n\n if (nodeClick === 'rootToNode') {\n _this._rootToNode(node);\n } else if (nodeClick === 'link') {\n var itemModel = node.getModel();\n var link = itemModel.get('link');\n\n if (link) {\n var linkTarget = itemModel.get('target', true) || '_blank';\n windowOpen(link, linkTarget);\n }\n }\n\n targetFound = true;\n }\n });\n });\n };\n /**\n * @private\n */\n\n\n SunburstView.prototype._rootToNode = function (node) {\n if (node !== this.seriesModel.getViewRoot()) {\n this.api.dispatchAction({\n type: ROOT_TO_NODE_ACTION,\n from: this.uid,\n seriesId: this.seriesModel.id,\n targetNode: node\n });\n }\n };\n /**\n * @implement\n */\n\n\n SunburstView.prototype.containPoint = function (point, seriesModel) {\n var treeRoot = seriesModel.getData();\n var itemLayout = treeRoot.getItemLayout(0);\n\n if (itemLayout) {\n var dx = point[0] - itemLayout.cx;\n var dy = point[1] - itemLayout.cy;\n var radius = Math.sqrt(dx * dx + dy * dy);\n return radius <= itemLayout.r && radius >= itemLayout.r0;\n }\n };\n\n SunburstView.type = 'sunburst';\n return SunburstView;\n}(ChartView);\n\nexport default SunburstView;"]},"metadata":{},"sourceType":"module"} |