@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
139 lines (138 loc) • 6.36 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 __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 base_1 = __importDefault(require("./base"));
var bind_1 = __importDefault(require("../../../utils/bind"));
var chart_drill_down_1 = require("../../../services/chart-drill-down");
var chart_common_action_1 = require("../../../services/chart-common-action");
var chart_dataset_1 = require("../transforms/chart-dataset");
var RelationBaseChartStore = /** @class */ (function (_super) {
__extends(RelationBaseChartStore, _super);
function RelationBaseChartStore(getProps) {
var _this = _super.call(this, getProps) || this;
_this.onEvents = {
click: _this.handleDrillDown
};
return _this;
}
Object.defineProperty(RelationBaseChartStore.prototype, "chartDataset", {
get: function () {
var _a = this.chartStyleService, currentMetrics = _a.currentMetrics, unitTransformer = _a.unitTransformer;
return chart_dataset_1.formatUnit(this.dataset, currentMetrics.reduce(function (res, metric) {
res[metric] = unitTransformer;
return res;
}, {}));
},
enumerable: false,
configurable: true
});
Object.defineProperty(RelationBaseChartStore.prototype, "metricIndex", {
get: function () {
var currentMetrics = this.chartStyleService.currentMetrics;
return this.dataset.fields.findIndex(function (field) { return field.key === currentMetrics[0]; });
},
enumerable: false,
configurable: true
});
Object.defineProperty(RelationBaseChartStore.prototype, "metricDisplayName", {
get: function () {
var metricIndex = this.metricIndex;
var fields = this.dataset.fields;
if (metricIndex === -1) {
return 'unknown';
}
return fields[metricIndex].name;
},
enumerable: false,
configurable: true
});
Object.defineProperty(RelationBaseChartStore.prototype, "fromBucketIndex", {
get: function () {
var currentBuckets = this.chartStyleService.currentBuckets;
return this.dataset.fields.findIndex(function (field) { return field.key === currentBuckets[0]; });
},
enumerable: false,
configurable: true
});
Object.defineProperty(RelationBaseChartStore.prototype, "toBucketIndex", {
get: function () {
var currentBuckets = this.chartStyleService.currentBuckets;
return this.dataset.fields.findIndex(function (field) { return field.key === currentBuckets[1]; });
},
enumerable: false,
configurable: true
});
RelationBaseChartStore.prototype.handleDrillDown = function (params) {
if (params.dataType !== 'edge') {
return;
}
this.onAction({
fromField: lodash_1.get(this.chartStyleService.currentBuckets, 0),
toField: lodash_1.get(this.chartStyleService.currentBuckets, 1),
fromFieldValue: lodash_1.get(params, ['data', 'source']),
toFieldValue: lodash_1.get(params, ['data', 'target']),
metricField: lodash_1.get(this.chartStyleService.currentMetrics, 0),
metricValue: lodash_1.get(params, 'value'),
fields: this.fields
}, chart_drill_down_1.RelationChartDrillDownService, chart_common_action_1.RelationChartActionService);
};
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "chartDataset", null);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "metricIndex", null);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "metricDisplayName", null);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "fromBucketIndex", null);
__decorate([
mobx_1.computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "toBucketIndex", null);
__decorate([
bind_1.default,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], RelationBaseChartStore.prototype, "handleDrillDown", null);
return RelationBaseChartStore;
}(base_1.default));
exports.default = RelationBaseChartStore;