UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

171 lines (170 loc) 7.35 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 { isUndefined } from 'lodash'; import bind from '../../../../../utils/bind'; import { ELabelValueType } from '../../../../../constants/map-style'; import OneDLegend from '../../components/one-d-legend'; import OneDChartStyleService from '../one-d'; import { styleOption } from '../base'; var MapChartStyleService = /** @class */ (function (_super) { __extends(MapChartStyleService, _super); function MapChartStyleService(chart) { var _this = _super.call(this, chart) || this; _this.legend = new OneDLegend({ 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 = [ ELabelValueType.FIELD, ELabelValueType.VALUE ]; _this.showCalculable = chart.showCalculable !== false; _this.showVisualMap = chart.showVisualMap !== false; _this.labelLayoutType = isUndefined(chart.labelLayoutType) ? true : chart.labelLayoutType; _this.labelValueType = chart.labelValueType && chart.labelValueType.length ? chart.labelValueType : [ELabelValueType.FIELD]; _this.legend = new OneDLegend(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([ styleOption(), __metadata("design:type", Boolean) ], MapChartStyleService.prototype, "showCalculable", void 0); __decorate([ styleOption(), __metadata("design:type", Boolean) ], MapChartStyleService.prototype, "showVisualMap", void 0); __decorate([ styleOption(), __metadata("design:type", String) ], MapChartStyleService.prototype, "dataDetailsValue", void 0); __decorate([ styleOption(), __metadata("design:type", Boolean) ], MapChartStyleService.prototype, "labelLayoutType", void 0); __decorate([ styleOption(), __metadata("design:type", Array) ], MapChartStyleService.prototype, "labelValueType", void 0); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Boolean]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "setShowVisualMap", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Boolean]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "setShowCalculable", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Boolean]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "setLabelLayoutType", null); __decorate([ bind, action, __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "setLabelValueType", null); __decorate([ action, __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", void 0) ], MapChartStyleService.prototype, "set", null); return MapChartStyleService; }(OneDChartStyleService)); export default MapChartStyleService;