@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
74 lines (73 loc) • 3.08 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 __());
};
})();
import ChartDrillDownService from './base-chart-drill';
/**
* 状态矩阵图实现DrillDown Service
*/
var HoneycombDrillDownService = /** @class */ (function (_super) {
__extends(HoneycombDrillDownService, _super);
function HoneycombDrillDownService() {
return _super !== null && _super.apply(this, arguments) || this;
}
HoneycombDrillDownService.prototype.toSearchAutoEvent = function (params) {
var _this = this;
var buckets = [];
var metrics = [];
buckets = params.currentBuckets.map(function (field) {
return _this.generateBucket(field.key, _this.getFieldValue(params.fields, params.originRow, field.key), params.fields);
});
metrics = params.currentMetrics.map(function (field) {
return _this.generateBucket(field.key, _this.getFieldValue(params.fields, params.originRow, field.key), params.fields);
});
return this.generateValidResults({ buckets: buckets, metrics: metrics });
};
HoneycombDrillDownService.prototype.toDrillDownToken = function (params) {
var fields = params.fields, currentBuckets = params.currentBuckets, currentMetrics = params.currentMetrics, originRow = params.originRow;
var firstBuckets = currentBuckets.length
? {
label: currentBuckets[0],
value: this.getFieldValue(fields, originRow, currentBuckets[0].key)
}
: {};
var firstMetric = currentBuckets.length
? {
label: currentBuckets[0],
value: this.getFieldValue(fields, originRow, currentMetrics[0].key)
}
: {};
var row = {};
fields.forEach(function (_a, index) {
var name = _a.name;
row[name] = originRow[index][0];
});
return {
row: row,
click: {
name: firstBuckets.label,
value: firstBuckets.value,
name1: firstMetric.label,
value1: firstMetric.value
}
};
};
HoneycombDrillDownService.prototype.getFieldValue = function (fields, originRow, field) {
var index = fields.findIndex(function (_a) {
var name = _a.name;
return name === field;
});
return originRow[index][0];
};
return HoneycombDrillDownService;
}(ChartDrillDownService));
export default HoneycombDrillDownService;