UNPKG

@qn-pandora/pandora-visualization

Version:

Pandora 通用可视化库

111 lines (110 loc) 5.04 kB
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 __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; import { first, get } from 'lodash'; import { EChartConditionType } from '@qn-pandora/app-sdk'; import bind from '../../../../utils/bind'; import { toTreeDataSource } from '../../transforms/tree-chart'; import { TreeTableDrillDownService } from '../../../../services/chart-drill-down'; import { TreeTableActionService } from '../../../../services/chart-common-action'; import BaseTableStore from '../store'; import { filterBuiltInFields } from '../transform'; var TreeTableStore = /** @class */ (function (_super) { __extends(TreeTableStore, _super); function TreeTableStore() { return _super !== null && _super.apply(this, arguments) || this; } TreeTableStore.prototype.getInitTableData = function (dataset) { var columns = []; var dataSource = []; var fields = filterBuiltInFields(dataset).fields; var buckets = fields.filter(function (item) { return item.type === EChartConditionType.Bucket; }); var metrics = fields.filter(function (item) { return item.type === EChartConditionType.Metric || item.type === EChartConditionType.SparkLine; }); var firstBucket = first(buckets); if (firstBucket) { columns = __spread([firstBucket], metrics).map(function (field) { return ({ key: field.key, title: field.name || field.key, dataIndex: field.key, type: field.type || '', fieldType: field.fieldType || '' }); }); var data = dataset.rows.map(function (row) { var data = {}; dataset.fields.forEach(function (schema, index) { return (data[schema.key] = row[index][0]); }); return data; }); dataSource = toTreeDataSource(data, buckets, metrics.map(function (m) { return m.key; })); } return { columns: columns, dataSource: dataSource }; }; TreeTableStore.prototype.handleTableCellClick = function (record, clickField, clickValue, event) { var position = { clientX: get(event, ['clientX']), clientY: get(event, ['clientY']) }; this.onAction({ record: record, clickField: clickField, clickValue: clickValue, fields: this.fields, position: position }, TreeTableDrillDownService, TreeTableActionService); }; __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object]), __metadata("design:returntype", void 0) ], TreeTableStore.prototype, "getInitTableData", null); __decorate([ bind, __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object, Object, Object]), __metadata("design:returntype", void 0) ], TreeTableStore.prototype, "handleTableCellClick", null); return TreeTableStore; }(BaseTableStore)); export default TreeTableStore;