UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

170 lines (169 loc) 7.61 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 } from 'mobx'; import { InitSplitter, InitGaugeTitleFont, InitDataFontStyle } from '../../../../../constants/single-style'; import bind from '../../../../../utils/bind'; import SingleBaseStyleService from './base'; import { styleOption } from '../base'; /** * 环状类型单值图的通用属性 * 主要是仪表盘、百分比环图 */ var SingleCircularStyleService = /** @class */ (function (_super) { __extends(SingleCircularStyleService, _super); function SingleCircularStyleService(option) { var _this = _super.call(this, option) || this; // 仪表盘, 百分比环图的宽度 _this.circularWidth = 0; // 仪表盘或者占比图的标题 _this.gaugeTitleName = ''; // 标题位置 _this.gaugeTitlePosition = "center" /* Center */; // 标题样式 _this.gaugeTitleFont = InitGaugeTitleFont; // 单值图半径比例 _this.radiusRatio = 0; // 阈值分段情况 _this.gaugeSplitters = InitSplitter; _this.titleDataFont = option.titleDataFont || InitDataFontStyle; _this.circularWidth = option.circularWidth || 0; _this.gaugeTitleName = option.gaugeTitleName || ''; _this.gaugeTitlePosition = option.gaugeTitlePosition || "center" /* Center */; _this.gaugeTitleFont = option.gaugeTitleFont || InitGaugeTitleFont; _this.radiusRatio = option.radiusRatio; var gaugeSplitter = option.gaugeSplitters || InitSplitter; // 从 option 的 gaugeSplitters 获取 min max var _a = _this.getGaugeBoundWithColorSplitter(gaugeSplitter), min = _a.min, max = _a.max; var gaugeMin = option.gaugeMin || min; var gaugeMax = option.gaugeMax || max; if (gaugeMin.toString() === '') { gaugeMin = 0; } if (gaugeMax.toString() === '') { gaugeMax = 100; } _this.gaugeMin = gaugeMin; _this.gaugeMax = gaugeMax; // 设置 gaugeSplitters _this.gaugeSplitters = _this.calcGaugeSplitters(gaugeSplitter, _this.gaugeMin, _this.gaugeMax); return _this; } SingleCircularStyleService.prototype.getOptions = function () { return __assign(__assign({}, _super.prototype.getOptions.call(this)), { circularWidth: this.circularWidth, radiusRatio: this.radiusRatio, gaugeTitleName: this.gaugeTitleName, gaugeTitlePosition: this.gaugeTitlePosition, gaugeTitleFont: this.gaugeTitleFont }); }; SingleCircularStyleService.prototype.setCircularWidth = function (circularWidth) { this.circularWidth = circularWidth; }; SingleCircularStyleService.prototype.setGaugeTitleName = function (gaugeTitleName) { this.gaugeTitleName = gaugeTitleName; }; SingleCircularStyleService.prototype.setGaugeTitlePosition = function (gaugeTitlePosition) { this.gaugeTitlePosition = gaugeTitlePosition; }; SingleCircularStyleService.prototype.setGaugeTitleFont = function (gaugeTitleFont) { this.gaugeTitleFont = gaugeTitleFont; }; SingleCircularStyleService.prototype.setRadiusRatio = function (radiusRatio) { this.radiusRatio = radiusRatio; }; __decorate([ styleOption(), __metadata("design:type", Number) ], SingleCircularStyleService.prototype, "circularWidth", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], SingleCircularStyleService.prototype, "gaugeTitleName", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], SingleCircularStyleService.prototype, "gaugeTitlePosition", void 0); __decorate([ styleOption(), __metadata("design:type", Object) ], SingleCircularStyleService.prototype, "gaugeTitleFont", void 0); __decorate([ styleOption(), __metadata("design:type", Number) ], SingleCircularStyleService.prototype, "radiusRatio", void 0); __decorate([ styleOption(), __metadata("design:type", Object) ], SingleCircularStyleService.prototype, "gaugeSplitters", void 0); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], SingleCircularStyleService.prototype, "setCircularWidth", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], SingleCircularStyleService.prototype, "setGaugeTitleName", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], SingleCircularStyleService.prototype, "setGaugeTitlePosition", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], SingleCircularStyleService.prototype, "setGaugeTitleFont", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], SingleCircularStyleService.prototype, "setRadiusRatio", null); return SingleCircularStyleService; }(SingleBaseStyleService)); export default SingleCircularStyleService; export function getChartInitStyle(option, initFirst) { if (initFirst === void 0) { initFirst = true; } var newOption = { currentBuckets: option.buckets, currentMetrics: [] }; return initFirst ? __assign(__assign({}, newOption), option) : __assign(__assign({}, option), newOption); }