UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

70 lines 2.83 kB
import { CornerNodeType, Node, CornerHeader as OriginCornerHeader, } from '@antv/s2'; import { AxisCornerCell } from '../cell/axis-corner-cell'; export class AxisCornerHeader extends OriginCornerHeader { /** * Get corner Header by config */ static getCornerHeader(options) { var _a; const { panelBBox, cornerBBox, seriesNumberWidth, layoutResult, spreadsheet, } = options; const { y, viewportWidth, viewportHeight } = panelBBox; const { originalWidth: cornerOriginalWidth, width: cornerWidth } = cornerBBox; const { axisColsHierarchy } = layoutResult; const position = { x: cornerBBox.x, y: y + viewportHeight, }; const height = (_a = axisColsHierarchy === null || axisColsHierarchy === void 0 ? void 0 : axisColsHierarchy.height) !== null && _a !== void 0 ? _a : 0; const cornerNodes = this.getCornerNodes({ position, width: cornerOriginalWidth, height, layoutResult, seriesNumberWidth, spreadsheet, }); return new AxisCornerHeader({ nodes: cornerNodes, position, width: cornerWidth, height, originalWidth: cornerOriginalWidth, originalHeight: height, viewportWidth, viewportHeight, seriesNumberWidth, spreadsheet, }); } static getCornerNodes(options) { const cornerNodes = []; // 创建角头区域竖轴 const { layoutResult, spreadsheet } = options; const { axisColsHierarchy } = layoutResult; const colAxisNode = axisColsHierarchy === null || axisColsHierarchy === void 0 ? void 0 : axisColsHierarchy.sampleNodeForLastLevel; if (colAxisNode) { const cornerNode = new Node({ id: colAxisNode.id, field: colAxisNode.field, value: spreadsheet.dataSet.getFieldName(colAxisNode.field), x: 0, y: 0, width: spreadsheet.facet.cornerBBox.originalWidth, height: colAxisNode.height, isPivotMode: true, cornerType: CornerNodeType.Col, spreadsheet, }); cornerNodes.push(cornerNode); } return cornerNodes; } getCellInstance(node) { const headerConfig = this.getHeaderConfig(); const { spreadsheet } = headerConfig; const { axisCornerCell } = spreadsheet.options; return ((axisCornerCell === null || axisCornerCell === void 0 ? void 0 : axisCornerCell(node, spreadsheet, headerConfig)) || new AxisCornerCell(node, spreadsheet, headerConfig)); } } //# sourceMappingURL=axis-corner.js.map