qauMaWeb/node_modules/.cache/babel-loader/c9884a3f525fde98c52edbe3790...

1 line
23 KiB
JSON

{"ast":null,"code":"import \"core-js/modules/es.function.name.js\";\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*/\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*/\n// TODO clockwise\nimport IndicatorAxis from './IndicatorAxis.js';\nimport IntervalScale from '../../scale/Interval.js';\nimport * as numberUtil from '../../util/number.js';\nimport { map, each, isString, isNumber } from 'zrender/lib/core/util.js';\nimport { alignScaleTicks } from '../axisAlignTicks.js';\n\nvar Radar =\n/** @class */\nfunction () {\n function Radar(radarModel, ecModel, api) {\n /**\r\n *\r\n * Radar dimensions\r\n */\n this.dimensions = [];\n this._model = radarModel;\n this._indicatorAxes = map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {\n var dim = 'indicator_' + idx;\n var indicatorAxis = new IndicatorAxis(dim, new IntervalScale() // (indicatorModel.get('axisType') === 'log') ? new LogScale() : new IntervalScale()\n );\n indicatorAxis.name = indicatorModel.get('name'); // Inject model and axis\n\n indicatorAxis.model = indicatorModel;\n indicatorModel.axis = indicatorAxis;\n this.dimensions.push(dim);\n return indicatorAxis;\n }, this);\n this.resize(radarModel, api);\n }\n\n Radar.prototype.getIndicatorAxes = function () {\n return this._indicatorAxes;\n };\n\n Radar.prototype.dataToPoint = function (value, indicatorIndex) {\n var indicatorAxis = this._indicatorAxes[indicatorIndex];\n return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);\n }; // TODO: API should be coordToPoint([coord, indicatorIndex])\n\n\n Radar.prototype.coordToPoint = function (coord, indicatorIndex) {\n var indicatorAxis = this._indicatorAxes[indicatorIndex];\n var angle = indicatorAxis.angle;\n var x = this.cx + coord * Math.cos(angle);\n var y = this.cy - coord * Math.sin(angle);\n return [x, y];\n };\n\n Radar.prototype.pointToData = function (pt) {\n var dx = pt[0] - this.cx;\n var dy = pt[1] - this.cy;\n var radius = Math.sqrt(dx * dx + dy * dy);\n dx /= radius;\n dy /= radius;\n var radian = Math.atan2(-dy, dx); // Find the closest angle\n // FIXME index can calculated directly\n\n var minRadianDiff = Infinity;\n var closestAxis;\n var closestAxisIdx = -1;\n\n for (var i = 0; i < this._indicatorAxes.length; i++) {\n var indicatorAxis = this._indicatorAxes[i];\n var diff = Math.abs(radian - indicatorAxis.angle);\n\n if (diff < minRadianDiff) {\n closestAxis = indicatorAxis;\n closestAxisIdx = i;\n minRadianDiff = diff;\n }\n }\n\n return [closestAxisIdx, +(closestAxis && closestAxis.coordToData(radius))];\n };\n\n Radar.prototype.resize = function (radarModel, api) {\n var center = radarModel.get('center');\n var viewWidth = api.getWidth();\n var viewHeight = api.getHeight();\n var viewSize = Math.min(viewWidth, viewHeight) / 2;\n this.cx = numberUtil.parsePercent(center[0], viewWidth);\n this.cy = numberUtil.parsePercent(center[1], viewHeight);\n this.startAngle = radarModel.get('startAngle') * Math.PI / 180; // radius may be single value like `20`, `'80%'`, or array like `[10, '80%']`\n\n var radius = radarModel.get('radius');\n\n if (isString(radius) || isNumber(radius)) {\n radius = [0, radius];\n }\n\n this.r0 = numberUtil.parsePercent(radius[0], viewSize);\n this.r = numberUtil.parsePercent(radius[1], viewSize);\n each(this._indicatorAxes, function (indicatorAxis, idx) {\n indicatorAxis.setExtent(this.r0, this.r);\n var angle = this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length; // Normalize to [-PI, PI]\n\n angle = Math.atan2(Math.sin(angle), Math.cos(angle));\n indicatorAxis.angle = angle;\n }, this);\n };\n\n Radar.prototype.update = function (ecModel, api) {\n var indicatorAxes = this._indicatorAxes;\n var radarModel = this._model;\n each(indicatorAxes, function (indicatorAxis) {\n indicatorAxis.scale.setExtent(Infinity, -Infinity);\n });\n ecModel.eachSeriesByType('radar', function (radarSeries, idx) {\n if (radarSeries.get('coordinateSystem') !== 'radar' // @ts-ignore\n || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel) {\n return;\n }\n\n var data = radarSeries.getData();\n each(indicatorAxes, function (indicatorAxis) {\n indicatorAxis.scale.unionExtentFromData(data, data.mapDimension(indicatorAxis.dim));\n });\n }, this);\n var splitNumber = radarModel.get('splitNumber');\n var dummyScale = new IntervalScale();\n dummyScale.setExtent(0, splitNumber);\n dummyScale.setInterval(1); // Force all the axis fixing the maxSplitNumber.\n\n each(indicatorAxes, function (indicatorAxis, idx) {\n alignScaleTicks(indicatorAxis.scale, indicatorAxis.model, dummyScale);\n });\n };\n\n Radar.prototype.convertToPixel = function (ecModel, finder, value) {\n console.warn('Not implemented.');\n return null;\n };\n\n Radar.prototype.convertFromPixel = function (ecModel, finder, pixel) {\n console.warn('Not implemented.');\n return null;\n };\n\n Radar.prototype.containPoint = function (point) {\n console.warn('Not implemented.');\n return false;\n };\n\n Radar.create = function (ecModel, api) {\n var radarList = [];\n ecModel.eachComponent('radar', function (radarModel) {\n var radar = new Radar(radarModel, ecModel, api);\n radarList.push(radar);\n radarModel.coordinateSystem = radar;\n });\n ecModel.eachSeriesByType('radar', function (radarSeries) {\n if (radarSeries.get('coordinateSystem') === 'radar') {\n // Inject coordinate system\n // @ts-ignore\n radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];\n }\n });\n return radarList;\n };\n /**\r\n * Radar dimensions is based on the data\r\n */\n\n\n Radar.dimensions = [];\n return Radar;\n}();\n\nexport default Radar;","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src/qingge-Market/qingge-vue/node_modules/echarts/lib/coord/radar/Radar.js"],"names":["IndicatorAxis","IntervalScale","numberUtil","map","each","isString","isNumber","alignScaleTicks","Radar","radarModel","ecModel","api","dimensions","_model","_indicatorAxes","getIndicatorModels","indicatorModel","idx","dim","indicatorAxis","name","get","model","axis","push","resize","prototype","getIndicatorAxes","dataToPoint","value","indicatorIndex","coordToPoint","dataToCoord","coord","angle","x","cx","Math","cos","y","cy","sin","pointToData","pt","dx","dy","radius","sqrt","radian","atan2","minRadianDiff","Infinity","closestAxis","closestAxisIdx","i","length","diff","abs","coordToData","center","viewWidth","getWidth","viewHeight","getHeight","viewSize","min","parsePercent","startAngle","PI","r0","r","setExtent","update","indicatorAxes","scale","eachSeriesByType","radarSeries","getComponent","data","getData","unionExtentFromData","mapDimension","splitNumber","dummyScale","setInterval","convertToPixel","finder","console","warn","convertFromPixel","pixel","containPoint","point","create","radarList","eachComponent","radar","coordinateSystem"],"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;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\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\n// TODO clockwise\r\nimport IndicatorAxis from './IndicatorAxis.js';\r\nimport IntervalScale from '../../scale/Interval.js';\r\nimport * as numberUtil from '../../util/number.js';\r\nimport { map, each, isString, isNumber } from 'zrender/lib/core/util.js';\r\nimport { alignScaleTicks } from '../axisAlignTicks.js';\r\n\r\nvar Radar =\r\n/** @class */\r\nfunction () {\r\n function Radar(radarModel, ecModel, api) {\r\n /**\r\n *\r\n * Radar dimensions\r\n */\r\n this.dimensions = [];\r\n this._model = radarModel;\r\n this._indicatorAxes = map(radarModel.getIndicatorModels(), function (indicatorModel, idx) {\r\n var dim = 'indicator_' + idx;\r\n var indicatorAxis = new IndicatorAxis(dim, new IntervalScale() // (indicatorModel.get('axisType') === 'log') ? new LogScale() : new IntervalScale()\r\n );\r\n indicatorAxis.name = indicatorModel.get('name'); // Inject model and axis\r\n\r\n indicatorAxis.model = indicatorModel;\r\n indicatorModel.axis = indicatorAxis;\r\n this.dimensions.push(dim);\r\n return indicatorAxis;\r\n }, this);\r\n this.resize(radarModel, api);\r\n }\r\n\r\n Radar.prototype.getIndicatorAxes = function () {\r\n return this._indicatorAxes;\r\n };\r\n\r\n Radar.prototype.dataToPoint = function (value, indicatorIndex) {\r\n var indicatorAxis = this._indicatorAxes[indicatorIndex];\r\n return this.coordToPoint(indicatorAxis.dataToCoord(value), indicatorIndex);\r\n }; // TODO: API should be coordToPoint([coord, indicatorIndex])\r\n\r\n\r\n Radar.prototype.coordToPoint = function (coord, indicatorIndex) {\r\n var indicatorAxis = this._indicatorAxes[indicatorIndex];\r\n var angle = indicatorAxis.angle;\r\n var x = this.cx + coord * Math.cos(angle);\r\n var y = this.cy - coord * Math.sin(angle);\r\n return [x, y];\r\n };\r\n\r\n Radar.prototype.pointToData = function (pt) {\r\n var dx = pt[0] - this.cx;\r\n var dy = pt[1] - this.cy;\r\n var radius = Math.sqrt(dx * dx + dy * dy);\r\n dx /= radius;\r\n dy /= radius;\r\n var radian = Math.atan2(-dy, dx); // Find the closest angle\r\n // FIXME index can calculated directly\r\n\r\n var minRadianDiff = Infinity;\r\n var closestAxis;\r\n var closestAxisIdx = -1;\r\n\r\n for (var i = 0; i < this._indicatorAxes.length; i++) {\r\n var indicatorAxis = this._indicatorAxes[i];\r\n var diff = Math.abs(radian - indicatorAxis.angle);\r\n\r\n if (diff < minRadianDiff) {\r\n closestAxis = indicatorAxis;\r\n closestAxisIdx = i;\r\n minRadianDiff = diff;\r\n }\r\n }\r\n\r\n return [closestAxisIdx, +(closestAxis && closestAxis.coordToData(radius))];\r\n };\r\n\r\n Radar.prototype.resize = function (radarModel, api) {\r\n var center = radarModel.get('center');\r\n var viewWidth = api.getWidth();\r\n var viewHeight = api.getHeight();\r\n var viewSize = Math.min(viewWidth, viewHeight) / 2;\r\n this.cx = numberUtil.parsePercent(center[0], viewWidth);\r\n this.cy = numberUtil.parsePercent(center[1], viewHeight);\r\n this.startAngle = radarModel.get('startAngle') * Math.PI / 180; // radius may be single value like `20`, `'80%'`, or array like `[10, '80%']`\r\n\r\n var radius = radarModel.get('radius');\r\n\r\n if (isString(radius) || isNumber(radius)) {\r\n radius = [0, radius];\r\n }\r\n\r\n this.r0 = numberUtil.parsePercent(radius[0], viewSize);\r\n this.r = numberUtil.parsePercent(radius[1], viewSize);\r\n each(this._indicatorAxes, function (indicatorAxis, idx) {\r\n indicatorAxis.setExtent(this.r0, this.r);\r\n var angle = this.startAngle + idx * Math.PI * 2 / this._indicatorAxes.length; // Normalize to [-PI, PI]\r\n\r\n angle = Math.atan2(Math.sin(angle), Math.cos(angle));\r\n indicatorAxis.angle = angle;\r\n }, this);\r\n };\r\n\r\n Radar.prototype.update = function (ecModel, api) {\r\n var indicatorAxes = this._indicatorAxes;\r\n var radarModel = this._model;\r\n each(indicatorAxes, function (indicatorAxis) {\r\n indicatorAxis.scale.setExtent(Infinity, -Infinity);\r\n });\r\n ecModel.eachSeriesByType('radar', function (radarSeries, idx) {\r\n if (radarSeries.get('coordinateSystem') !== 'radar' // @ts-ignore\r\n || ecModel.getComponent('radar', radarSeries.get('radarIndex')) !== radarModel) {\r\n return;\r\n }\r\n\r\n var data = radarSeries.getData();\r\n each(indicatorAxes, function (indicatorAxis) {\r\n indicatorAxis.scale.unionExtentFromData(data, data.mapDimension(indicatorAxis.dim));\r\n });\r\n }, this);\r\n var splitNumber = radarModel.get('splitNumber');\r\n var dummyScale = new IntervalScale();\r\n dummyScale.setExtent(0, splitNumber);\r\n dummyScale.setInterval(1); // Force all the axis fixing the maxSplitNumber.\r\n\r\n each(indicatorAxes, function (indicatorAxis, idx) {\r\n alignScaleTicks(indicatorAxis.scale, indicatorAxis.model, dummyScale);\r\n });\r\n };\r\n\r\n Radar.prototype.convertToPixel = function (ecModel, finder, value) {\r\n console.warn('Not implemented.');\r\n return null;\r\n };\r\n\r\n Radar.prototype.convertFromPixel = function (ecModel, finder, pixel) {\r\n console.warn('Not implemented.');\r\n return null;\r\n };\r\n\r\n Radar.prototype.containPoint = function (point) {\r\n console.warn('Not implemented.');\r\n return false;\r\n };\r\n\r\n Radar.create = function (ecModel, api) {\r\n var radarList = [];\r\n ecModel.eachComponent('radar', function (radarModel) {\r\n var radar = new Radar(radarModel, ecModel, api);\r\n radarList.push(radar);\r\n radarModel.coordinateSystem = radar;\r\n });\r\n ecModel.eachSeriesByType('radar', function (radarSeries) {\r\n if (radarSeries.get('coordinateSystem') === 'radar') {\r\n // Inject coordinate system\r\n // @ts-ignore\r\n radarSeries.coordinateSystem = radarList[radarSeries.get('radarIndex') || 0];\r\n }\r\n });\r\n return radarList;\r\n };\r\n /**\r\n * Radar dimensions is based on the data\r\n */\r\n\r\n\r\n Radar.dimensions = [];\r\n return Radar;\r\n}();\r\n\r\nexport default Radar;"]},"metadata":{},"sourceType":"module"}