@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
79 lines (78 loc) • 3.28 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 __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var base_chart_action_1 = __importDefault(require("./base-chart-action"));
/**
* 状态矩阵图实现Link Service
*/
var HoneycombActionService = /** @class */ (function (_super) {
__extends(HoneycombActionService, _super);
function HoneycombActionService() {
return _super !== null && _super.apply(this, arguments) || this;
}
HoneycombActionService.prototype.toEvent = 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 });
};
HoneycombActionService.prototype.toActionToken = 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: currentMetrics[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
}
};
};
HoneycombActionService.prototype.getFieldValue = function (fields, originRow, field) {
var index = fields.findIndex(function (_a) {
var name = _a.name;
return name === field;
});
return originRow[index][0];
};
return HoneycombActionService;
}(base_chart_action_1.default));
exports.default = HoneycombActionService;