@qn-pandora/pandora-visualization
Version:
Pandora 通用可视化库
69 lines (68 loc) • 2.83 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 { get, size, last } from 'lodash';
import ChartDrillDownService from './base-chart-drill';
/**
* 旭日图实现DrillDown Service
*/
var SunburstDrillDownService = /** @class */ (function (_super) {
__extends(SunburstDrillDownService, _super);
function SunburstDrillDownService() {
return _super !== null && _super.apply(this, arguments) || this;
}
SunburstDrillDownService.prototype.toSearchAutoEvent = function (params) {
var _this = this;
var buckets = [];
var metrics = [];
var lastBucketInfo = last(params.treePathInfo);
var treeInfo = params.treePathInfo
.slice(1, size(params.treePathInfo) - 1)
.concat(lastBucketInfo);
buckets = params.currentBuckets.map(function (key, index) {
return _this.generateBucket(key, get(treeInfo, [index, 'name']), params.fields);
});
metrics = params.currentMetrics.map(function (key) {
return _this.generateMetric(key, get(lastBucketInfo, 'value'));
});
return this.generateValidResults({ buckets: buckets, metrics: metrics });
};
SunburstDrillDownService.prototype.toDrillDownToken = function (params) {
var _a;
var lastBucketInfo = last(params.treePathInfo);
var treeInfo = params.treePathInfo
.slice(1, size(params.treePathInfo) - 2)
.concat(lastBucketInfo);
var firstBucket = params.currentBuckets[0];
var firstBucketValue = get(treeInfo, [0, 'name']);
var firstMetric = params.currentBuckets[0];
var firstMetricValue = get(lastBucketInfo, 'value');
var row = (_a = {},
_a[firstMetric] = firstMetricValue,
_a);
params.currentBuckets.forEach(function (bucket, index) {
row[bucket] = get(treeInfo, [index, 'name']);
});
return {
row: row,
click: {
name: firstBucket,
value: firstBucketValue,
name1: firstMetric,
value1: firstMetricValue
}
};
};
return SunburstDrillDownService;
}(ChartDrillDownService));
export default SunburstDrillDownService;