1 line
16 KiB
JSON
1 line
16 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 { eachAfter, eachBefore } from './traversalHelper.js';\nimport { init, firstWalk, secondWalk, separation as sep, radialCoordinate, getViewRect } from './layoutHelper.js';\nexport default function treeLayout(ecModel, api) {\n ecModel.eachSeriesByType('tree', function (seriesModel) {\n commonLayout(seriesModel, api);\n });\n}\n\nfunction commonLayout(seriesModel, api) {\n var layoutInfo = getViewRect(seriesModel, api);\n seriesModel.layoutInfo = layoutInfo;\n var layout = seriesModel.get('layout');\n var width = 0;\n var height = 0;\n var separation = null;\n\n if (layout === 'radial') {\n width = 2 * Math.PI;\n height = Math.min(layoutInfo.height, layoutInfo.width) / 2;\n separation = sep(function (node1, node2) {\n return (node1.parentNode === node2.parentNode ? 1 : 2) / node1.depth;\n });\n } else {\n width = layoutInfo.width;\n height = layoutInfo.height;\n separation = sep();\n }\n\n var virtualRoot = seriesModel.getData().tree.root;\n var realRoot = virtualRoot.children[0];\n\n if (realRoot) {\n init(virtualRoot);\n eachAfter(realRoot, firstWalk, separation);\n virtualRoot.hierNode.modifier = -realRoot.hierNode.prelim;\n eachBefore(realRoot, secondWalk);\n var left_1 = realRoot;\n var right_1 = realRoot;\n var bottom_1 = realRoot;\n eachBefore(realRoot, function (node) {\n var x = node.getLayout().x;\n\n if (x < left_1.getLayout().x) {\n left_1 = node;\n }\n\n if (x > right_1.getLayout().x) {\n right_1 = node;\n }\n\n if (node.depth > bottom_1.depth) {\n bottom_1 = node;\n }\n });\n var delta = left_1 === right_1 ? 1 : separation(left_1, right_1) / 2;\n var tx_1 = delta - left_1.getLayout().x;\n var kx_1 = 0;\n var ky_1 = 0;\n var coorX_1 = 0;\n var coorY_1 = 0;\n\n if (layout === 'radial') {\n kx_1 = width / (right_1.getLayout().x + delta + tx_1); // here we use (node.depth - 1), bucause the real root's depth is 1\n\n ky_1 = height / (bottom_1.depth - 1 || 1);\n eachBefore(realRoot, function (node) {\n coorX_1 = (node.getLayout().x + tx_1) * kx_1;\n coorY_1 = (node.depth - 1) * ky_1;\n var finalCoor = radialCoordinate(coorX_1, coorY_1);\n node.setLayout({\n x: finalCoor.x,\n y: finalCoor.y,\n rawX: coorX_1,\n rawY: coorY_1\n }, true);\n });\n } else {\n var orient_1 = seriesModel.getOrient();\n\n if (orient_1 === 'RL' || orient_1 === 'LR') {\n ky_1 = height / (right_1.getLayout().x + delta + tx_1);\n kx_1 = width / (bottom_1.depth - 1 || 1);\n eachBefore(realRoot, function (node) {\n coorY_1 = (node.getLayout().x + tx_1) * ky_1;\n coorX_1 = orient_1 === 'LR' ? (node.depth - 1) * kx_1 : width - (node.depth - 1) * kx_1;\n node.setLayout({\n x: coorX_1,\n y: coorY_1\n }, true);\n });\n } else if (orient_1 === 'TB' || orient_1 === 'BT') {\n kx_1 = width / (right_1.getLayout().x + delta + tx_1);\n ky_1 = height / (bottom_1.depth - 1 || 1);\n eachBefore(realRoot, function (node) {\n coorX_1 = (node.getLayout().x + tx_1) * kx_1;\n coorY_1 = orient_1 === 'TB' ? (node.depth - 1) * ky_1 : height - (node.depth - 1) * ky_1;\n node.setLayout({\n x: coorX_1,\n y: coorY_1\n }, true);\n });\n }\n }\n }\n}","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src/qingge-Market/qingge-vue/node_modules/echarts/lib/chart/tree/treeLayout.js"],"names":["eachAfter","eachBefore","init","firstWalk","secondWalk","separation","sep","radialCoordinate","getViewRect","treeLayout","ecModel","api","eachSeriesByType","seriesModel","commonLayout","layoutInfo","layout","get","width","height","Math","PI","min","node1","node2","parentNode","depth","virtualRoot","getData","tree","root","realRoot","children","hierNode","modifier","prelim","left_1","right_1","bottom_1","node","x","getLayout","delta","tx_1","kx_1","ky_1","coorX_1","coorY_1","finalCoor","setLayout","y","rawX","rawY","orient_1","getOrient"],"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,EAAoBC,UAApB,QAAsC,sBAAtC;AACA,SAASC,IAAT,EAAeC,SAAf,EAA0BC,UAA1B,EAAsCC,UAAU,IAAIC,GAApD,EAAyDC,gBAAzD,EAA2EC,WAA3E,QAA8F,mBAA9F;AACA,eAAe,SAASC,UAAT,CAAoBC,OAApB,EAA6BC,GAA7B,EAAkC;AAC/CD,EAAAA,OAAO,CAACE,gBAAR,CAAyB,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b,KAAL,GAAa,CAAd,IAAmBkB,IAAvC,GAA8C1B,KAAK,GAAG,CAACqB,IAAI,CAACb,KAAL,GAAa,CAAd,IAAmBkB,IAAnF;AACAL,UAAAA,IAAI,CAACU,SAAL,CAAe;AACbT,YAAAA,CAAC,EAAEM,OADU;AAEbI,YAAAA,CAAC,EAAEH;AAFU,WAAf,EAGG,IAHH;AAID,SAPS,CAAV;AAQD,OAXD,MAWO,IAAIM,QAAQ,KAAK,IAAb,IAAqBA,QAAQ,KAAK,IAAtC,EAA4C;AACjDT,QAAAA,IAAI,GAAG1B,KAAK,IAAImB,OAAO,CAACI,SAAR,GAAoBD,CAApB,GAAwBE,KAAxB,GAAgCC,IAApC,CAAZ;AACAE,QAAAA,IAAI,GAAG1B,MAAM,IAAImB,QAAQ,CAACZ,KAAT,GAAiB,CAAjB,IAAsB,CAA1B,CAAb;AACAzB,QAAAA,UAAU,CAAC8B,QAAD,EAAW,UAAUQ,IAAV,EAAgB;AACnCO,UAAAA,OAAO,GAAG,CAACP,IAAI,CAACE,SAAL,GAAiBD,CAAjB,GAAqBG,IAAtB,IAA8BC,IAAxC;AACAG,UAAAA,OAAO,GAAGM,QAAQ,KAAK,IAAb,GAAoB,CAACd,IAAI,CAACb,KAAL,GAAa,CAAd,IAAmBmB,IAAvC,GAA8C1B,MAAM,GAAG,CAACoB,IAAI,CAACb,KAAL,GAAa,CAAd,IAAmBmB,IAApF;AACAN,UAAAA,IAAI,CAACU,SAAL,CAAe;AACbT,YAAAA,CAAC,EAAEM,OADU;AAEbI,YAAAA,CAAC,EAAEH;AAFU,WAAf,EAGG,IAHH;AAID,SAPS,CAAV;AAQD;AACF;AACF;AACF","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 { eachAfter, eachBefore } from './traversalHelper.js';\r\nimport { init, firstWalk, secondWalk, separation as sep, radialCoordinate, getViewRect } from './layoutHelper.js';\r\nexport default function treeLayout(ecModel, api) {\r\n ecModel.eachSeriesByType('tree', function (seriesModel) {\r\n commonLayout(seriesModel, api);\r\n });\r\n}\r\n\r\nfunction commonLayout(seriesModel, api) {\r\n var layoutInfo = getViewRect(seriesModel, api);\r\n seriesModel.layoutInfo = layoutInfo;\r\n var layout = seriesModel.get('layout');\r\n var width = 0;\r\n var height = 0;\r\n var separation = null;\r\n\r\n if (layout === 'radial') {\r\n width = 2 * Math.PI;\r\n height = Math.min(layoutInfo.height, layoutInfo.width) / 2;\r\n separation = sep(function (node1, node2) {\r\n return (node1.parentNode === node2.parentNode ? 1 : 2) / node1.depth;\r\n });\r\n } else {\r\n width = layoutInfo.width;\r\n height = layoutInfo.height;\r\n separation = sep();\r\n }\r\n\r\n var virtualRoot = seriesModel.getData().tree.root;\r\n var realRoot = virtualRoot.children[0];\r\n\r\n if (realRoot) {\r\n init(virtualRoot);\r\n eachAfter(realRoot, firstWalk, separation);\r\n virtualRoot.hierNode.modifier = -realRoot.hierNode.prelim;\r\n eachBefore(realRoot, secondWalk);\r\n var left_1 = realRoot;\r\n var right_1 = realRoot;\r\n var bottom_1 = realRoot;\r\n eachBefore(realRoot, function (node) {\r\n var x = node.getLayout().x;\r\n\r\n if (x < left_1.getLayout().x) {\r\n left_1 = node;\r\n }\r\n\r\n if (x > right_1.getLayout().x) {\r\n right_1 = node;\r\n }\r\n\r\n if (node.depth > bottom_1.depth) {\r\n bottom_1 = node;\r\n }\r\n });\r\n var delta = left_1 === right_1 ? 1 : separation(left_1, right_1) / 2;\r\n var tx_1 = delta - left_1.getLayout().x;\r\n var kx_1 = 0;\r\n var ky_1 = 0;\r\n var coorX_1 = 0;\r\n var coorY_1 = 0;\r\n\r\n if (layout === 'radial') {\r\n kx_1 = width / (right_1.getLayout().x + delta + tx_1); // here we use (node.depth - 1), bucause the real root's depth is 1\r\n\r\n ky_1 = height / (bottom_1.depth - 1 || 1);\r\n eachBefore(realRoot, function (node) {\r\n coorX_1 = (node.getLayout().x + tx_1) * kx_1;\r\n coorY_1 = (node.depth - 1) * ky_1;\r\n var finalCoor = radialCoordinate(coorX_1, coorY_1);\r\n node.setLayout({\r\n x: finalCoor.x,\r\n y: finalCoor.y,\r\n rawX: coorX_1,\r\n rawY: coorY_1\r\n }, true);\r\n });\r\n } else {\r\n var orient_1 = seriesModel.getOrient();\r\n\r\n if (orient_1 === 'RL' || orient_1 === 'LR') {\r\n ky_1 = height / (right_1.getLayout().x + delta + tx_1);\r\n kx_1 = width / (bottom_1.depth - 1 || 1);\r\n eachBefore(realRoot, function (node) {\r\n coorY_1 = (node.getLayout().x + tx_1) * ky_1;\r\n coorX_1 = orient_1 === 'LR' ? (node.depth - 1) * kx_1 : width - (node.depth - 1) * kx_1;\r\n node.setLayout({\r\n x: coorX_1,\r\n y: coorY_1\r\n }, true);\r\n });\r\n } else if (orient_1 === 'TB' || orient_1 === 'BT') {\r\n kx_1 = width / (right_1.getLayout().x + delta + tx_1);\r\n ky_1 = height / (bottom_1.depth - 1 || 1);\r\n eachBefore(realRoot, function (node) {\r\n coorX_1 = (node.getLayout().x + tx_1) * kx_1;\r\n coorY_1 = orient_1 === 'TB' ? (node.depth - 1) * ky_1 : height - (node.depth - 1) * ky_1;\r\n node.setLayout({\r\n x: coorX_1,\r\n y: coorY_1\r\n }, true);\r\n });\r\n }\r\n }\r\n }\r\n}"]},"metadata":{},"sourceType":"module"} |