UNPKG

bytev-charts-beta1.0

Version:

测试版-1.0,版本号为小版本; 基于echarts和JavaScript及ES6封装的一个可以直接调用的图表组件库,内置主题设计,简单快捷,且支持用户自定义配置; npm 安装方式: npm install bytev-charts 若启动提示还需额外install插件,则运行 npm install @babel/runtime-corejs2 即可;

157 lines (122 loc) 6.41 kB
import _Reflect$construct from "@babel/runtime-corejs2/core-js/reflect/construct"; import "core-js/modules/es.object.to-string.js"; import _classCallCheck from "@babel/runtime-corejs2/helpers/classCallCheck"; import _createClass from "@babel/runtime-corejs2/helpers/createClass"; import _assertThisInitialized from "@babel/runtime-corejs2/helpers/assertThisInitialized"; import _get from "@babel/runtime-corejs2/helpers/get"; import _inherits from "@babel/runtime-corejs2/helpers/inherits"; import _possibleConstructorReturn from "@babel/runtime-corejs2/helpers/possibleConstructorReturn"; import _getPrototypeOf from "@babel/runtime-corejs2/helpers/getPrototypeOf"; import _defineProperty from "@babel/runtime-corejs2/helpers/defineProperty"; import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign"; import _JSON$stringify from "@babel/runtime-corejs2/core-js/json/stringify"; import "core-js/modules/es.array.concat.js"; import "core-js/modules/web.timers.js"; import "core-js/modules/es.regexp.exec.js"; import "core-js/modules/es.string.replace.js"; function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = _Reflect$construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_Reflect$construct) return false; if (_Reflect$construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(_Reflect$construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } import DoughnutLeftRightComponent from "../DoughnutLeftRightComponent.class.js"; /* * 瞄准星环形饼图 * */ var DoughnutBeadSight = /*#__PURE__*/function (_DoughnutLeftRightCom) { _inherits(DoughnutBeadSight, _DoughnutLeftRightCom); var _super = _createSuper(DoughnutBeadSight); function DoughnutBeadSight() { var _this; _classCallCheck(this, DoughnutBeadSight); for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _super.call.apply(_super, [this].concat(args)); _defineProperty(_assertThisInitialized(_this), "name", 'DoughnutBeadSight'); return _this; } _createClass(DoughnutBeadSight, [{ key: "buildByteVModel", value: function buildByteVModel() { var _this$byteVModel; _get(_getPrototypeOf(DoughnutBeadSight.prototype), "buildByteVModel", this).call(this); //切换皮肤时判断之前是否有自定义radius var radius = ((_this$byteVModel = this.byteVModel) === null || _this$byteVModel === void 0 ? void 0 : _this$byteVModel.radius) || ''; this.byteVModel.radius = radius ? radius : this.theme.series.doughnutBeadSightRadius; } }, { key: "setRadiusByOption", value: function setRadiusByOption() { _get(_getPrototypeOf(DoughnutBeadSight.prototype), "setRadiusByOption", this).call(this); this.theme.series.convertDoughnutBeadSight(this.byteVModel.radius); } }, { key: "setData", value: function setData(data) { _get(_getPrototypeOf(DoughnutBeadSight.prototype), "setData", this).call(this, data); var arr = []; //获取添加了分割线样式的环形图数据 arr = this.buildDoughnutSpilt2Data(data); //装数据的环 _Object$assign(this.theme.series.doughnutBeadSight_pie, { data: arr, label: { show: false, position: 'center' } }); this.byteVModel.series.push(this.theme.series.doughnutBeadSight_pie); this.setCenterByOption(this.byteVModel.series); this.setRadiusByOption(this.byteVModel.series); this.componentInstance.setOption(this.byteVModel, true); this.playAnimation(false); } }, { key: "playAnimation", value: function playAnimation() { var _this2 = this; var play = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true; _get(_getPrototypeOf(DoughnutBeadSight.prototype), "playAnimation", this).call(this); var series = [//最外层的X装饰 JSON.parse(_JSON$stringify(this.theme.series.doughnutBeadSight_X)), //最外层的上下渐变缺失装饰环(上部缺失) JSON.parse(_JSON$stringify(this.theme.series.doughnutBeadSight_OuterBroken)), //最外层的缺失环下面的细装饰环 this.theme.series.doughnutBeadSight_OuterThinDoughnut, //最内层的圆装饰环 JSON.parse(_JSON$stringify(this.theme.series.doughnutBeadSight_InnerThinDoughnut))]; this.setCenterByOption(series); //瞄准星环形饼图的各个装饰环 this.animationInstance.setOption({ animationDuration: 1, series: series }); if (!play) { window.ByteVChartsInterval.remove(this.componentInstance.id); return; } //周期定时旋转装饰 var i = 1; var r = .2; // let arr = [1,2,3,4,5,6,7,8,9] setTimeout(function () { window.ByteVChartsInterval.add(_this2.componentInstance.id, function () { var opt = _this2.animationInstance.getOption(); opt.series[0].startAngle += i; var r0 = opt.series[3].radius[0].replace('%', '') - 0; var r1 = opt.series[3].radius[1].replace('%', '') - 0; r0 += r; r1 += r; if (opt.series[0].startAngle >= 150) { i = 0 - i; r = 0 - r; } else if (opt.series[0].startAngle <= 120) { i = Math.abs(i); r = Math.abs(r); } opt.series[1].startAngle = opt.series[0].startAngle; opt.series[3].radius[0] = r0 + '%'; opt.series[3].radius[1] = r1 + '%'; _this2.animationInstance.setOption(opt); }, 200); }, this.theme.animationDuration * .6); } }, { key: "offAnimation", value: function offAnimation() { _get(_getPrototypeOf(DoughnutBeadSight.prototype), "offAnimation", this).call(this); this.playAnimation(false); } }]); return DoughnutBeadSight; }(DoughnutLeftRightComponent); export { DoughnutBeadSight as default };