UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

317 lines (316 loc) 12.2 kB
"use strict"; 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 app_sdk_1 = require("@qn-pandora/app-sdk"); var bind_1 = __importDefault(require("../../../../utils/bind")); var chart_style_1 = require("../../../../constants/chart-style"); var getUnitTransformer = app_sdk_1.utils.unit.getUnitTransformer; var MainAxis = /** @class */ (function () { function MainAxis(option) { this.name = option.name || ''; this.nameMode = option.nameMode || "on" /* On */; this.minMode = option.min ? option.minMode || chart_style_1.EAxisMinMaxMode.Custom : option.minMode || chart_style_1.EAxisMinMaxMode.Auto; this.maxMode = option.max ? option.maxMode || chart_style_1.EAxisMinMaxMode.Custom : option.maxMode || chart_style_1.EAxisMinMaxMode.Auto; this.min = option.min; this.max = option.max; this.labelShowMode = option.labelShowMode || "showauto" /* ShowAuto */; this.labelRotation = option.labelRotation || "0" /* Zero */; this.field = option.field || ''; this.unit = option.unit || ['none', 'short']; this.precision = lodash_1.isUndefined(option.precision) ? 2 : option.precision; this.type = option.type || "category" /* Category */; this.intervalType = option.intervalType || "auto" /* Auto */; this.splitNumber = option.splitNumber; this.interval = option.interval; } Object.defineProperty(MainAxis.prototype, "option", { get: function () { return { name: this.name, nameMode: this.nameMode, labelShowMode: this.labelShowMode, labelRotation: this.labelRotation, field: this.field, unit: this.unit, precision: this.precision, type: this.type || "category" /* Category */, minMode: this.minMode, maxMode: this.maxMode, min: this.min, max: this.max, intervalType: this.intervalType, splitNumber: this.splitNumber, interval: this.interval }; }, enumerable: false, configurable: true }); Object.defineProperty(MainAxis.prototype, "unitTransformer", { get: function () { var precision = this.precision; if (this.unit) { var currentUnit_1 = this.unit[1]; return function (value) { return getUnitTransformer(currentUnit_1)(value, precision); }; } return function (value) { return getUnitTransformer('short')(value, precision); }; }, enumerable: false, configurable: true }); MainAxis.prototype.setAxisType = function (type) { this.type = type; }; MainAxis.prototype.setName = function (name) { this.name = name; }; MainAxis.prototype.setNameMode = function (nameMode) { this.nameMode = nameMode; }; MainAxis.prototype.setLabelShowMode = function (labelShowMode) { this.labelShowMode = labelShowMode; }; MainAxis.prototype.setLabelRotation = function (labelRotation) { this.labelRotation = labelRotation; }; MainAxis.prototype.setField = function (field) { this.field = field; }; MainAxis.prototype.setUnit = function (unit) { this.unit = unit; }; MainAxis.prototype.setPrecision = function (precision) { this.precision = precision; }; MainAxis.prototype.setMinMode = function (mode) { this.minMode = mode; }; MainAxis.prototype.setMaxMode = function (mode) { this.maxMode = mode; }; MainAxis.prototype.setMin = function (min) { this.min = min; }; MainAxis.prototype.setMax = function (max) { this.max = max; }; MainAxis.prototype.setIntervalType = function (intervalType) { this.intervalType = intervalType; }; MainAxis.prototype.setSplitNumber = function (splitNumber) { this.splitNumber = splitNumber; }; MainAxis.prototype.setInterval = function (interval) { this.interval = interval; }; MainAxis.prototype.set = function (option) { this.name = option.name || ''; this.nameMode = option.nameMode || "on" /* On */; this.labelShowMode = option.labelShowMode || "showauto" /* ShowAuto */; this.labelRotation = option.labelRotation || "0" /* Zero */; this.field = option.field || ''; this.unit = option.unit || ['none', 'short']; this.precision = lodash_1.isUndefined(option.precision) ? 2 : option.precision; this.type = option.type || "category" /* Category */; }; __decorate([ mobx_1.observable, __metadata("design:type", String) ], MainAxis.prototype, "name", void 0); __decorate([ mobx_1.observable, __metadata("design:type", String) ], MainAxis.prototype, "nameMode", void 0); __decorate([ mobx_1.observable, __metadata("design:type", String) ], MainAxis.prototype, "labelShowMode", void 0); __decorate([ mobx_1.observable, __metadata("design:type", String) ], MainAxis.prototype, "labelRotation", void 0); __decorate([ mobx_1.observable.ref, __metadata("design:type", String) ], MainAxis.prototype, "field", void 0); __decorate([ mobx_1.observable.ref, __metadata("design:type", Array) ], MainAxis.prototype, "unit", void 0); __decorate([ mobx_1.observable, __metadata("design:type", Number) ], MainAxis.prototype, "precision", void 0); __decorate([ mobx_1.observable, __metadata("design:type", String) ], MainAxis.prototype, "type", void 0); __decorate([ mobx_1.observable, __metadata("design:type", String) ], MainAxis.prototype, "minMode", void 0); __decorate([ mobx_1.observable, __metadata("design:type", String) ], MainAxis.prototype, "maxMode", void 0); __decorate([ mobx_1.observable, __metadata("design:type", Number) ], MainAxis.prototype, "min", void 0); __decorate([ mobx_1.observable, __metadata("design:type", Number) ], MainAxis.prototype, "max", void 0); __decorate([ mobx_1.observable, __metadata("design:type", String) ], MainAxis.prototype, "intervalType", void 0); __decorate([ mobx_1.observable, __metadata("design:type", Number) ], MainAxis.prototype, "splitNumber", void 0); __decorate([ mobx_1.observable, __metadata("design:type", Number) ], MainAxis.prototype, "interval", void 0); __decorate([ mobx_1.computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], MainAxis.prototype, "option", null); __decorate([ mobx_1.computed, __metadata("design:type", Object), __metadata("design:paramtypes", []) ], MainAxis.prototype, "unitTransformer", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setAxisType", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setName", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setNameMode", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setLabelShowMode", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setLabelRotation", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setField", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Array]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setUnit", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setPrecision", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setMinMode", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setMaxMode", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setMin", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setMax", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [String]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setIntervalType", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setSplitNumber", null); __decorate([ bind_1.default, mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Number]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "setInterval", null); __decorate([ mobx_1.action, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], MainAxis.prototype, "set", null); return MainAxis; }()); exports.default = MainAxis;