UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

176 lines (175 loc) 7.78 kB
"use strict"; 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); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var mobx_1 = require("mobx"); var lodash_1 = require("lodash"); var bind_1 = __importDefault(require("../../../../../utils/bind")); var map_style_1 = require("../../../../../constants/map-style"); var one_d_legend_1 = __importDefault(require("../../components/one-d-legend")); var one_d_1 = __importDefault(require("../one-d")); var base_1 = require("../base"); var MapChartStyleService = /** @class */ (function (_super) { __extends(MapChartStyleService, _super); function MapChartStyleService(chart) { var _this = _super.call(this, chart) || this; _this.legend = new one_d_legend_1.default({ position: "right" /* Right */, legendValueFormat: ["percent" /* Percent */, "value" /* Value */], percentDecimals: 2 }); // 是否显示拖拽手柄 _this.showCalculable = true; // 是否显示视觉映射元素 _this.showVisualMap = true; // 是否显示各区域数据详情 _this.dataDetailsValue = "on" /* On */; // 值标签显示方式 自适应|全部 // todo://新版本echarts时恢复该配置ELabelLayoutType _this.labelLayoutType = false; // 值标签显示 字段 & 数值 _this.labelValueType = [ map_style_1.ELabelValueType.FIELD, map_style_1.ELabelValueType.VALUE ]; _this.showCalculable = chart.showCalculable !== false; _this.showVisualMap = chart.showVisualMap !== false; _this.labelLayoutType = lodash_1.isUndefined(chart.labelLayoutType) ? true : chart.labelLayoutType; _this.labelValueType = chart.labelValueType && chart.labelValueType.length ? chart.labelValueType : [map_style_1.ELabelValueType.FIELD]; _this.legend = new one_d_legend_1.default(chart.legend || { position: "right" /* Right */, width: 0, height: 0, legendValueFormat: ["percent" /* Percent */, "value" /* Value */], percentDecimals: 2 }); _this.dataDetailsValue = chart.dataDetailsValue || "on" /* On */; return _this; } MapChartStyleService.prototype.getOptions = function () { return __assign(__assign({}, _super.prototype.getOptions.call(this)), { legend: this.legend.option, showCalculable: this.showCalculable, showVisualMap: this.showVisualMap, dataDetailsValue: this.dataDetailsValue, labelLayoutType: this.labelLayoutType, labelValueType: this.labelValueType }); }; MapChartStyleService.prototype.setShowVisualMap = function (showVisualMap) { this.showVisualMap = showVisualMap; }; MapChartStyleService.prototype.setShowCalculable = function (showCalculable) { this.showCalculable = showCalculable; }; MapChartStyleService.prototype.setLabelLayoutType = function (labelLayoutType) { this.labelLayoutType = labelLayoutType; }; MapChartStyleService.prototype.setLabelValueType = function (labelValueType) { this.labelValueType = labelValueType; }; MapChartStyleService.prototype.set = function (key, value) { var _this = this; _super.prototype.set.call(this, key, value); if (typeof key !== 'object') { return; } var allowNil = !!value; var obj = key; this.executeFieldHandlers(obj, [ { field: 'legend', handler: function (legend) { _this.legend.set(legend); } } ], allowNil); }; __decorate([ base_1.styleOption(), __metadata("design:type", Boolean) ], MapChartStyleService.prototype, "showCalculable", void 0); __decorate([ base_1.styleOption(), __metadata("design:type", Boolean) ], MapChartStyleService.prototype, "showVisualMap", void 0); __decorate([ base_1.styleOption(), __metadata("design:type", String) ], MapChartStyleService.prototype, "dataDetailsValue", void 0); __decorate([ base_1.styleOption(), __metadata("design:type", Boolean) ], MapChartStyleService.prototype, "labelLayoutType", void 0); __decorate([ base_1.styleOption(), __metadata("design:type", Array) ], MapChartStyleService.prototype, "labelValueType", void 0); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Boolean]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "setShowVisualMap", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Boolean]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "setShowCalculable", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Boolean]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "setLabelLayoutType", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "setLabelValueType", null); __decorate([ mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "set", null); return MapChartStyleService; }(one_d_1.default)); exports.default = MapChartStyleService;