@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
250 lines (249 loc) • 10.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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
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 __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
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 bind_1 = __importDefault(require("../../../../../utils/bind"));
var constants_1 = require("../../../../../constants");
var base_1 = __importStar(require("../base"));
var TimelineMaxDataSize = 20;
var TimeLineStyleService = /** @class */ (function (_super) {
__extends(TimeLineStyleService, _super);
function TimeLineStyleService(chart) {
var _this = _super.call(this, chart) || this;
_this.chartType = constants_1.ChartType.TimeLine;
_this.labelField = '';
_this.startField = '';
_this.durationField = '';
_this.axisPosition = "top" /* Top */;
_this.maxZoom = "none" /* None */;
_this.minZoom = "none" /* None */;
_this.eventBackGround = '';
_this.dataSize = TimelineMaxDataSize;
_this.labelField = chart.labelField || '';
_this.startField = chart.startField || '';
_this.durationField = chart.durationField || '';
_this.axisPosition = chart.axisPosition || "top" /* Top */;
_this.maxZoom = chart.maxZoom || "none" /* None */;
_this.minZoom = chart.minZoom || "none" /* None */;
_this.eventBackGround = chart.eventBackGround;
_this.dataSize = chart.dataSize || TimelineMaxDataSize;
return _this;
}
TimeLineStyleService.getChartInitStyle = function (option, initFirst) {
if (initFirst === void 0) { initFirst = true; }
var fields = option.fields;
if (!fields) {
return option;
}
var fieldNames = fields.map(function (field) { return field.key; });
var newOption = {
startField: lodash_1.includes(fieldNames, '_time') ? '_time' : '',
durationField: lodash_1.includes(fieldNames, '_duration_second')
? '_duration_second'
: '',
labelField: lodash_1.includes(fieldNames, 'label')
? 'label'
: lodash_1.includes(fieldNames, '_raw')
? '_raw'
: ''
};
return initFirst ? __assign(__assign({}, newOption), option) : __assign(__assign({}, option), newOption);
};
Object.defineProperty(TimeLineStyleService.prototype, "contextOption", {
get: function () {
return {
buckets: [],
metrics: []
};
},
enumerable: false,
configurable: true
});
TimeLineStyleService.prototype.getOptions = function () {
return {
chartType: this.chartType,
labelField: this.labelField,
startField: this.startField,
durationField: this.durationField,
axisPosition: this.axisPosition,
maxZoom: this.maxZoom,
minZoom: this.minZoom,
eventBackGround: this.eventBackGround,
dataSize: this.dataSize
};
};
TimeLineStyleService.prototype.setLabelField = function (labelField) {
this.labelField = labelField;
};
TimeLineStyleService.prototype.setStartField = function (startField) {
this.startField = startField;
};
TimeLineStyleService.prototype.setDurationField = function (durationField) {
this.durationField = durationField;
};
TimeLineStyleService.prototype.setAxisPosition = function (axisPosition) {
this.axisPosition = axisPosition;
};
TimeLineStyleService.prototype.setMaxZoom = function (maxZoom) {
this.maxZoom = maxZoom;
};
TimeLineStyleService.prototype.setMinZoom = function (minZoom) {
this.minZoom = minZoom;
};
TimeLineStyleService.prototype.setEventBackGround = function (eventBackGround) {
this.eventBackGround = eventBackGround;
};
TimeLineStyleService.prototype.setDataSize = function (dataSize) {
this.dataSize = dataSize || TimelineMaxDataSize;
};
__decorate([
base_1.styleOption(),
__metadata("design:type", String)
], TimeLineStyleService.prototype, "labelField", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", String)
], TimeLineStyleService.prototype, "startField", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", String)
], TimeLineStyleService.prototype, "durationField", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", String)
], TimeLineStyleService.prototype, "axisPosition", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", String)
], TimeLineStyleService.prototype, "maxZoom", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", String)
], TimeLineStyleService.prototype, "minZoom", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", String)
], TimeLineStyleService.prototype, "eventBackGround", void 0);
__decorate([
base_1.styleOption(),
__metadata("design:type", Number)
], TimeLineStyleService.prototype, "dataSize", void 0);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], TimeLineStyleService.prototype, "contextOption", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], TimeLineStyleService.prototype, "setLabelField", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], TimeLineStyleService.prototype, "setStartField", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], TimeLineStyleService.prototype, "setDurationField", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], TimeLineStyleService.prototype, "setAxisPosition", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], TimeLineStyleService.prototype, "setMaxZoom", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], TimeLineStyleService.prototype, "setMinZoom", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [String]),
__metadata("design:returntype", void 0)
], TimeLineStyleService.prototype, "setEventBackGround", null);
__decorate([
bind_1.default,
mobx_1.action,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Number]),
__metadata("design:returntype", void 0)
], TimeLineStyleService.prototype, "setDataSize", null);
return TimeLineStyleService;
}(base_1.default));
exports.default = TimeLineStyleService;