@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
209 lines (208 loc) • 9.13 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 base_1 = __importDefault(require("../metric-panel/base"));
var base_2 = require("../base");
var chart_style_1 = require("../../../../../constants/chart-style");
var metric_panel_style_1 = require("../../../../../constants/metric-panel-style");
var MetricPanelStyleService = /** @class */ (function (_super) {
__extends(MetricPanelStyleService, _super);
function MetricPanelStyleService(option) {
var _this = _super.call(this, option) || this;
_this.chartType = chart_style_1.ChartType.MetricPanel;
_this.titleFontColor = '';
_this.metricStyles = [];
_this.colors = [];
_this.arrangement = metric_panel_style_1.EArrangement.Col;
_this.titleIcon = metric_panel_style_1.defaultIcon;
_this.set(option);
_this.metricStyles =
option.metricStyles ||
option.currentMetrics.map(function (item) {
var metriStyle = __assign({}, metric_panel_style_1.defaultMetricStyle);
metriStyle.metric = item;
return metriStyle;
});
_this.colors = option.colors || [];
_this.arrangement = option.arrangement || metric_panel_style_1.EArrangement.Col;
_this.titleIcon = option.titleIcon || metric_panel_style_1.defaultIcon;
return _this;
}
Object.defineProperty(MetricPanelStyleService.prototype, "contextOption", {
get: function () {
return {
currentBuckets: this.currentBuckets,
currentMetrics: this.currentMetrics,
metrics: this.currentMetrics,
buckets: this.currentBuckets,
metricDataConfigs: this.metricDataConfigs,
arrangement: this.arrangement
};
},
enumerable: false,
configurable: true
});
MetricPanelStyleService.prototype.setMetricStyles = function (metricStyles) {
this.metricStyles = metricStyles;
};
MetricPanelStyleService.prototype.setTitleFontSize = function (titleFontSize) {
this.titleFontSize = titleFontSize;
};
MetricPanelStyleService.prototype.setTitleFontColor = function (titleFontColor) {
this.titleFontColor = titleFontColor;
};
MetricPanelStyleService.prototype.setColors = function (colors) {
this.colors = colors;
};
MetricPanelStyleService.prototype.setCurrentMetrics = function (currentMetrics) {
this.currentMetrics = currentMetrics;
this.metricStyles = this.calMetricStyles(currentMetrics);
};
MetricPanelStyleService.prototype.setOptInit = function (width, height, titleFontSize, titleFontColor) {
this.width = width;
this.height = height;
this.titleFontSize = titleFontSize;
this.titleFontColor = titleFontColor;
};
MetricPanelStyleService.prototype.setArrangement = function (arrangement) {
this.arrangement = arrangement;
};
MetricPanelStyleService.prototype.setTitleColor = function (titleIcon) {
this.titleIcon = titleIcon;
};
MetricPanelStyleService.prototype.calMetricStyles = function (currentMetrics) {
var _this = this;
return currentMetrics.map(function (metric) {
var metriStyle = __assign({}, metric_panel_style_1.defaultMetricStyle);
metriStyle.metric = metric;
var style = _this.metricStyles.find(function (item) { return item.metric === metric; });
return style ? style : metriStyle;
});
};
__decorate([
base_2.styleOption(),
__metadata("design:type", Object)
], MetricPanelStyleService.prototype, "titleFontColor", void 0);
__decorate([
base_2.styleOption(),
__metadata("design:type", Array)
], MetricPanelStyleService.prototype, "metricStyles", void 0);
__decorate([
base_2.styleOption(),
__metadata("design:type", Array)
], MetricPanelStyleService.prototype, "colors", void 0);
__decorate([
base_2.styleOption(),
__metadata("design:type", String)
], MetricPanelStyleService.prototype, "arrangement", void 0);
__decorate([
base_2.styleOption(),
__metadata("design:type", Object)
], MetricPanelStyleService.prototype, "titleIcon", void 0);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], MetricPanelStyleService.prototype, "contextOption", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "setMetricStyles", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "setTitleFontSize", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "setTitleFontColor", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "setColors", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "setCurrentMetrics", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number, Number, Number, String]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "setOptInit", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "setArrangement", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "setTitleColor", null);
__decorate([
bind_1.default,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Array]),
__metadata("design:returntype", void 0)
], MetricPanelStyleService.prototype, "calMetricStyles", null);
return MetricPanelStyleService;
}(base_1.default));
exports.default = MetricPanelStyleService;