@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
144 lines (143 loc) • 6.4 kB
JavaScript
;
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 bind_1 = __importDefault(require("../../../../../utils/bind"));
var one_d_1 = __importDefault(require("../one-d"));
var base_1 = require("../base");
var metric_panel_style_1 = require("../../../../../constants/metric-panel-style");
var MetricBasePanelStyleService = /** @class */ (function (_super) {
__extends(MetricBasePanelStyleService, _super);
function MetricBasePanelStyleService(option) {
var _this = _super.call(this, option) || this;
_this.colorMode = metric_panel_style_1.EColorMode.NORMAL;
_this.titleFontSize = 0;
_this.width = 0;
_this.height = 0;
_this.pageSize = 0;
_this.autoplaySpeed = 0;
// 每个指标对应的数据的设置
_this.metricDataConfigs = [];
_this.set(option);
var metricDataConfigs = option.metricDataConfigs || [];
_this.metricDataConfigs = option.currentMetrics.map(function (_, index) {
if (metricDataConfigs.length > index) {
return metricDataConfigs[index];
}
return metric_panel_style_1.defaultDataConfig;
});
// 防止 color mode 配置冲突,例如: 单值图
_this.colorMode =
option.colorMode === metric_panel_style_1.EColorMode.INVERTED
? metric_panel_style_1.EColorMode.INVERTED
: metric_panel_style_1.EColorMode.NORMAL;
return _this;
}
MetricBasePanelStyleService.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);
};
MetricBasePanelStyleService.prototype.getOptions = function () {
return this.getStyleOptions();
};
MetricBasePanelStyleService.prototype.setMetricDataConfigs = function (metricDataConfigs) {
this.metricDataConfigs = metricDataConfigs.map(function (item) { return ({
precision: item.precision || 2,
unit: item.unit || ['none', 'none']
}); });
};
Object.defineProperty(MetricBasePanelStyleService.prototype, "contextOption", {
get: function () {
return {
currentBuckets: this.currentBuckets,
currentMetrics: this.currentMetrics,
metrics: this.currentMetrics,
buckets: this.currentBuckets,
metricDataConfigs: this.metricDataConfigs
};
},
enumerable: false,
configurable: true
});
__decorate([
base_1.styleOption(),
__metadata("design:type", Object)
], MetricBasePanelStyleService.prototype, "colorMode", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", Object)
], MetricBasePanelStyleService.prototype, "titleFontSize", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", Object)
], MetricBasePanelStyleService.prototype, "width", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", Object)
], MetricBasePanelStyleService.prototype, "height", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", Object)
], MetricBasePanelStyleService.prototype, "pageSize", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", Object)
], MetricBasePanelStyleService.prototype, "autoplaySpeed", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", Array)
], MetricBasePanelStyleService.prototype, "metricDataConfigs", void 0);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], MetricBasePanelStyleService.prototype, "setMetricDataConfigs", null);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], MetricBasePanelStyleService.prototype, "contextOption", null);
return MetricBasePanelStyleService;
}(one_d_1.default));
exports.default = MetricBasePanelStyleService;