UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

226 lines (225 loc) 9.09 kB
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { action, computed } from 'mobx'; import { includes } from 'lodash'; import bind from '../../../../../utils/bind'; import { ChartType } from '../../../../../constants'; import ChartStyleService, { styleOption } from '../base'; var TimelineMaxDataSize = 20; var TimeLineStyleService = /** @class */ (function (_super) { __extends(TimeLineStyleService, _super); function TimeLineStyleService(chart) { var _this = _super.call(this, chart) || this; _this.chartType = ChartType.TimeLine; _this.labelField = ''; _this.startField = ''; _this.durationField = ''; _this.axisPosition = "top" /* Top */; _this.maxZoom = "none" /* None */; _this.minZoom = "none" /* None */; _this.eventBackGround = ''; _this.dataSize = TimelineMaxDataSize; _this.labelField = chart.labelField || ''; _this.startField = chart.startField || ''; _this.durationField = chart.durationField || ''; _this.axisPosition = chart.axisPosition || "top" /* Top */; _this.maxZoom = chart.maxZoom || "none" /* None */; _this.minZoom = chart.minZoom || "none" /* None */; _this.eventBackGround = chart.eventBackGround; _this.dataSize = chart.dataSize || TimelineMaxDataSize; return _this; } TimeLineStyleService.getChartInitStyle = function (option, initFirst) { if (initFirst === void 0) { initFirst = true; } var fields = option.fields; if (!fields) { return option; } var fieldNames = fields.map(function (field) { return field.key; }); var newOption = { startField: includes(fieldNames, '_time') ? '_time' : '', durationField: includes(fieldNames, '_duration_second') ? '_duration_second' : '', labelField: includes(fieldNames, 'label') ? 'label' : includes(fieldNames, '_raw') ? '_raw' : '' }; return initFirst ? __assign(__assign({}, newOption), option) : __assign(__assign({}, option), newOption); }; Object.defineProperty(TimeLineStyleService.prototype, "contextOption", { get: function () { return { buckets: [], metrics: [] }; }, enumerable: false, configurable: true }); TimeLineStyleService.prototype.getOptions = function () { return { chartType: this.chartType, labelField: this.labelField, startField: this.startField, durationField: this.durationField, axisPosition: this.axisPosition, maxZoom: this.maxZoom, minZoom: this.minZoom, eventBackGround: this.eventBackGround, dataSize: this.dataSize }; }; TimeLineStyleService.prototype.setLabelField = function (labelField) { this.labelField = labelField; }; TimeLineStyleService.prototype.setStartField = function (startField) { this.startField = startField; }; TimeLineStyleService.prototype.setDurationField = function (durationField) { this.durationField = durationField; }; TimeLineStyleService.prototype.setAxisPosition = function (axisPosition) { this.axisPosition = axisPosition; }; TimeLineStyleService.prototype.setMaxZoom = function (maxZoom) { this.maxZoom = maxZoom; }; TimeLineStyleService.prototype.setMinZoom = function (minZoom) { this.minZoom = minZoom; }; TimeLineStyleService.prototype.setEventBackGround = function (eventBackGround) { this.eventBackGround = eventBackGround; }; TimeLineStyleService.prototype.setDataSize = function (dataSize) { this.dataSize = dataSize || TimelineMaxDataSize; }; __decorate([ styleOption(), __metadata("design:type", String) ], TimeLineStyleService.prototype, "labelField", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], TimeLineStyleService.prototype, "startField", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], TimeLineStyleService.prototype, "durationField", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], TimeLineStyleService.prototype, "axisPosition", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], TimeLineStyleService.prototype, "maxZoom", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], TimeLineStyleService.prototype, "minZoom", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], TimeLineStyleService.prototype, "eventBackGround", void 0); __decorate([ styleOption(), __metadata("design:type", Number) ], TimeLineStyleService.prototype, "dataSize", void 0); __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], TimeLineStyleService.prototype, "contextOption", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], TimeLineStyleService.prototype, "setLabelField", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], TimeLineStyleService.prototype, "setStartField", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], TimeLineStyleService.prototype, "setDurationField", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], TimeLineStyleService.prototype, "setAxisPosition", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], TimeLineStyleService.prototype, "setMaxZoom", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], TimeLineStyleService.prototype, "setMinZoom", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], TimeLineStyleService.prototype, "setEventBackGround", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], TimeLineStyleService.prototype, "setDataSize", null); return TimeLineStyleService; }(ChartStyleService)); export default TimeLineStyleService;