bytev-charts-beta1.0
Version:
测试版-1.0,版本号为小版本; 基于echarts和JavaScript及ES6封装的一个可以直接调用的图表组件库,内置主题设计,简单快捷,且支持用户自定义配置; npm 安装方式: npm install bytev-charts 若启动提示还需额外install插件,则运行 npm install @babel/runtime-corejs2 即可;
169 lines (132 loc) • 6.12 kB
JavaScript
import _Reflect$construct from "@babel/runtime-corejs2/core-js/reflect/construct";
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 _JSON$stringify from "@babel/runtime-corejs2/core-js/json/stringify";
import _Object$assign from "@babel/runtime-corejs2/core-js/object/assign";
import "core-js/modules/es.array.concat.js";
import "core-js/modules/es.array.sort.js";
import "core-js/modules/es.array.for-each.js";
import "core-js/modules/es.object.to-string.js";
import "core-js/modules/web.dom-collections.for-each.js";
import "core-js/modules/es.regexp.exec.js";
import "core-js/modules/es.string.replace.js";
import "core-js/modules/web.timers.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 PieComponent from "../PieComponent.class.js";
var RoseRadius = /*#__PURE__*/function (_PieComponent) {
_inherits(RoseRadius, _PieComponent);
var _super = _createSuper(RoseRadius);
function RoseRadius() {
var _this;
_classCallCheck(this, RoseRadius);
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", 'RoseRadius');
return _this;
}
_createClass(RoseRadius, [{
key: "buildByteVModel",
value: function buildByteVModel() {
_get(_getPrototypeOf(RoseRadius.prototype), "buildByteVModel", this).call(this); //增加自定义属性center和radius,让用户在初始化时即可以调整饼图的位置和大小,并影响与之对应生成的装饰饼们
this.byteVModel.radius = this.theme.series.rose.radius;
}
}, {
key: "setData",
value: function setData(data) {
var _this2 = this;
_get(_getPrototypeOf(RoseRadius.prototype), "setData", this).call(this, data);
data.sort(function (a, b) {
return a.value - b.value;
});
data.forEach(function (itm, i) {
var color = _this2.byteVModel.color[i % _this2.byteVModel.color.length];
itm.itemStyle = {
color: {
type: 'linear',
x: 0,
y: 0,
x2: 1,
y2: 0,
colorStops: [{
offset: 0,
color: color + '80' //'#fffffffa' // 0% 处的颜色
}, {
offset: 0.1,
color: color + '99' // 0% 处的颜色
}, {
offset: 0.6,
color: color + 'fa' // 0% 处的颜色
}, {
offset: 1,
color: color // 100% 处的颜色
}],
global: false // 缺省为 false
}
};
});
this.theme.series.rose.data = data;
this.theme.series.rose.roseType = 'radius';
this.theme.series.rose.itemStyle.borderRadius = 0;
this.byteVModel.series = [this.theme.series.rose];
this.setCenterByOption(this.byteVModel.series);
this.componentInstance.setOption(this.byteVModel);
this.playAnimation(false);
}
}, {
key: "playAnimation",
value: function playAnimation() {
var _this3 = this;
var play = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
_get(_getPrototypeOf(RoseRadius.prototype), "playAnimation", this).call(this);
var series = [JSON.parse(_JSON$stringify(this.theme.series.roseSolidCircle))];
this.setCenterByOption(series); //中间的装饰环
this.animationInstance.setOption({
animationDuration: 1,
series: series
});
if (!play) {
window.ByteVChartsInterval.remove(this.componentInstance.id);
return;
}
var r = .2;
var min = this.theme.series.roseSolidCircle.radius[1].replace('%', '') - 0; //周期定时
var i = 0;
setTimeout(function () {
window.ByteVChartsInterval.add(_this3.componentInstance.id, function () {
var opt = _this3.animationInstance.getOption();
var r1 = opt.series[0].radius[1].replace('%', '') - 0;
r1 += r;
if (r1 >= min * 1.2) {
r = 0 - r;
} else if (r1 <= min) {
r = Math.abs(r);
}
opt.series[0].radius[1] = r1 + '%';
_Object$assign(opt.series[0].itemStyle.color, _this3.theme.colorLinearXYArr[i]);
_this3.animationInstance.setOption(opt);
i = (i + 1) % _this3.theme.colorLinearXYArr.length;
}, 200);
}, this.theme.animationDuration * .6);
}
}, {
key: "offAnimation",
value: function offAnimation() {
_get(_getPrototypeOf(RoseRadius.prototype), "offAnimation", this).call(this);
this.playAnimation(false);
}
}]);
return RoseRadius;
}(PieComponent);
export { RoseRadius as default };