UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

165 lines (164 loc) 6.89 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 { computed, action } from 'mobx'; import { ChartType } from '../../../../../constants/chart-style'; import { EColorType, colorTypes, InitSplitter, defaultMultiColors, defaultSingleColors } from '../../../../../constants/honeycomb'; import bind from '../../../../../utils/bind'; import OneDChartStyleService from '../one-d'; import { styleOption } from '../base'; var HoneycombStyleService = /** @class */ (function (_super) { __extends(HoneycombStyleService, _super); function HoneycombStyleService(option) { var _this = _super.call(this, option) || this; _this.chartType = ChartType.Honeycomb; //最大半径 _this.maxRadius = 100; //最小半径 _this.minRadius = 10; //窝间距占半径比例,小数表示 _this.distance = 0.06; // 每个组每一行蜂窝数目 _this.honeycombNum = 6; // 图表每一行图表组数 _this.lineGroupNum = 3; _this.colorType = EColorType.Custom; _this.colorSplitter = InitSplitter; _this.colors = []; _this.set(option); _this.colorType = colorTypes.includes(option.colorType) ? option.colorType : EColorType.Custom; _this.colorSplitter = option.colorSplitter || InitSplitter; _this.colors = option.colors || []; return _this; } HoneycombStyleService.getChartInitStyle = function (option, initFirst) { if (initFirst === void 0) { initFirst = true; } var newOption = { currentBuckets: option.buckets.slice(0, 1), currentMetrics: option.metrics.slice(0, 1) }; return initFirst ? __assign(__assign({}, newOption), option) : __assign(__assign({}, option), newOption); }; HoneycombStyleService.prototype.getOptions = function () { return __assign(__assign({}, this.getStyleOptions()), { colorSplitter: this.colorSplitter }); }; Object.defineProperty(HoneycombStyleService.prototype, "contextOption", { get: function () { return { currentBuckets: this.currentBuckets, currentMetrics: this.currentMetrics, metrics: this.currentMetrics, buckets: this.currentBuckets }; }, enumerable: false, configurable: true }); HoneycombStyleService.prototype.setColorSplitter = function (colorSplitter) { this.colorSplitter = colorSplitter; }; HoneycombStyleService.prototype.setColors = function (colors) { this.colors = colors; }; HoneycombStyleService.prototype.setColorType = function (colorType) { this.colorType = colorType; if (colorType === EColorType.SingleColorGradient) { this.colors = defaultSingleColors; } if (colorType === EColorType.MultiColorGradient) { this.colors = defaultMultiColors; } }; __decorate([ styleOption(), __metadata("design:type", Number) ], HoneycombStyleService.prototype, "maxRadius", void 0); __decorate([ styleOption(), __metadata("design:type", Number) ], HoneycombStyleService.prototype, "minRadius", void 0); __decorate([ styleOption(), __metadata("design:type", Number) ], HoneycombStyleService.prototype, "distance", void 0); __decorate([ styleOption(), __metadata("design:type", Number) ], HoneycombStyleService.prototype, "honeycombNum", void 0); __decorate([ styleOption(), __metadata("design:type", Object) ], HoneycombStyleService.prototype, "lineGroupNum", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], HoneycombStyleService.prototype, "colorType", void 0); __decorate([ styleOption(), __metadata("design:type", Object) ], HoneycombStyleService.prototype, "colorSplitter", void 0); __decorate([ styleOption(), __metadata("design:type", Array) ], HoneycombStyleService.prototype, "colors", void 0); __decorate([ computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], HoneycombStyleService.prototype, "contextOption", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], HoneycombStyleService.prototype, "setColorSplitter", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", void 0) ], HoneycombStyleService.prototype, "setColors", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], HoneycombStyleService.prototype, "setColorType", null); return HoneycombStyleService; }(OneDChartStyleService)); export default HoneycombStyleService;