UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

147 lines (146 loc) 6.88 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 __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 __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; 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 bind_1 = __importDefault(require("../../../../../utils/bind")); var map_style_1 = require("../../../../../constants/map-style"); var map_1 = require("../../../constants/map/map"); var language_1 = require("../../../../../services/language"); var validateName_1 = require("../../../constants/map/validateName"); var store_1 = __importDefault(require("../store")); var BubbleChinaChartStore = /** @class */ (function (_super) { __extends(BubbleChinaChartStore, _super); function BubbleChinaChartStore() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.mapType = map_1.MapType.China; _this.getIsValidMapData = function (seriesNames) { var e_1, _a; // 中国地图: series的名字里只要出现中国地图允许的省份名字, 则为true, 若所有series的名字都不为中国地图所认识的省份名字,则返回false var geoLevel = _this.chartStyleService.geoLevel; try { for (var seriesNames_1 = __values(seriesNames), seriesNames_1_1 = seriesNames_1.next(); !seriesNames_1_1.done; seriesNames_1_1 = seriesNames_1.next()) { var name_1 = seriesNames_1_1.value; switch (geoLevel) { case map_style_1.EGeoLevel.PROVINCE: if (_this.chinaMapProvince.indexOf(_this.transformName(name_1)) > -1) { return true; } break; case map_style_1.EGeoLevel.CITY: if (_this.chinaMapCity.indexOf(_this.transformName(name_1)) > -1) { return true; } case map_style_1.EGeoLevel.AREA: if (_this.chinaMapArea.indexOf(_this.transformName(name_1)) > -1) { return true; } default: break; } } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (seriesNames_1_1 && !seriesNames_1_1.done && (_a = seriesNames_1.return)) _a.call(seriesNames_1); } finally { if (e_1) throw e_1.error; } } return false; }; return _this; } Object.defineProperty(BubbleChinaChartStore.prototype, "chinaMapProvince", { get: function () { return validateName_1.chinaMapProvince.map(function (item) { return language_1.formatString(item); }); }, enumerable: false, configurable: true }); Object.defineProperty(BubbleChinaChartStore.prototype, "chinaMapCity", { get: function () { return validateName_1.chinaMapCity.map(function (item) { return language_1.formatString(item); }); }, enumerable: false, configurable: true }); Object.defineProperty(BubbleChinaChartStore.prototype, "chinaMapArea", { get: function () { return validateName_1.chinaMapAREA.map(function (item) { return language_1.formatString(item); }); }, enumerable: false, configurable: true }); BubbleChinaChartStore.prototype.transformName = function (name) { if (name === void 0) { name = ''; } var res = name.replace(/^(.*?)(省|市|自治区|壮族自治区|回族自治区|维吾尔自治区|特别行政区)$/, '$1'); if (this.chinaMapProvince.indexOf(res) !== -1) { return res; } if (this.chinaMapCity.indexOf(res) !== -1) { return res; } if (this.chinaMapArea.indexOf(res) !== -1) { return res; } return ''; }; __decorate([ mobx_1.computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], BubbleChinaChartStore.prototype, "chinaMapProvince", null); __decorate([ mobx_1.computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], BubbleChinaChartStore.prototype, "chinaMapCity", null); __decorate([ mobx_1.computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], BubbleChinaChartStore.prototype, "chinaMapArea", null); __decorate([ bind_1.default, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], BubbleChinaChartStore.prototype, "transformName", null); return BubbleChinaChartStore; }(store_1.default)); exports.default = BubbleChinaChartStore;