@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
134 lines (133 loc) • 5.96 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);
};
import { computed } from 'mobx';
import { get } from 'lodash';
import BaseChartStore from './base';
import bind from '../../../utils/bind';
import { RelationChartDrillDownService } from '../../../services/chart-drill-down';
import { RelationChartActionService } from '../../../services/chart-common-action';
import { formatUnit } from '../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 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: get(this.chartStyleService.currentBuckets, 0),
toField: get(this.chartStyleService.currentBuckets, 1),
fromFieldValue: get(params, ['data', 'source']),
toFieldValue: get(params, ['data', 'target']),
metricField: get(this.chartStyleService.currentMetrics, 0),
metricValue: get(params, 'value'),
fields: this.fields
}, RelationChartDrillDownService, RelationChartActionService);
};
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "chartDataset", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "metricIndex", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "metricDisplayName", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "fromBucketIndex", null);
__decorate([
computed,
__metadata("design:type", Object),
__metadata("design:paramtypes", [])
], RelationBaseChartStore.prototype, "toBucketIndex", null);
__decorate([
bind,
__metadata("design:type", Function),
__metadata("design:paramtypes", [Object]),
__metadata("design:returntype", void 0)
], RelationBaseChartStore.prototype, "handleDrillDown", null);
return RelationBaseChartStore;
}(BaseChartStore));
export default RelationBaseChartStore;