UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

75 lines 3.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AxisRowCell = void 0; const g_1 = require("@antv/g"); const g2_1 = require("@antv/g2"); const s2_1 = require("@antv/s2"); const lodash_1 = require("lodash"); const constant_1 = require("../constant"); const chart_options_1 = require("../utils/chart-options"); const cell_type_1 = require("./cell-type"); class AxisRowCell extends s2_1.RowCell { get cellType() { return cell_type_1.AxisCellType.AXIS_ROW_CELL; } getBorderPositions() { return [s2_1.CellBorderPosition.BOTTOM, s2_1.CellBorderPosition.LEFT]; } isBolderText() { return false; } getInteractedCells() { var _a; return (_a = this.spreadsheet.interaction) === null || _a === void 0 ? void 0 : _a.getCells([ s2_1.CellType.ROW_CELL, cell_type_1.AxisCellType.AXIS_ROW_CELL, ]); } initCell() { this.drawBackgroundShape(); this.drawInteractiveBgShape(); this.drawInteractiveBorderShape(); this.drawTextShape(); this.drawBorders(); this.drawResizeAreaInLeaf(); this.update(); } getResizesArea() { return (0, s2_1.getOrCreateResizeAreaGroupById)(this.spreadsheet, constant_1.KEY_GROUP_ROW_AXIS_RESIZE_AREA); } drawTextShape() { if (this.spreadsheet.isPolarCoordinate()) { super.drawTextShape(); return; } this.drawAxisShape(); } getChartOptions() { var _a; const style = this.getStyle(); let customSpec = (_a = this.spreadsheet.options.chart) === null || _a === void 0 ? void 0 : _a.axisRowCellSpec; if ((0, lodash_1.isFunction)(customSpec)) { customSpec = customSpec(this); } return (0, s2_1.customMerge)(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, constant_1.DEFAULT_G2_SPEC), this.getBBoxByType(s2_1.CellClipBox.CONTENT_BOX)), (0, chart_options_1.getCoordinate)(this.spreadsheet)), (this.spreadsheet.isValueInCols() ? (0, chart_options_1.getAxisXOptions)(this.meta, this.spreadsheet) : (0, chart_options_1.getAxisYOptions)(this.meta, this.spreadsheet))), (0, chart_options_1.getAxisStyle)(style)), (0, chart_options_1.getTheme)(this.spreadsheet)), customSpec); } drawAxisShape() { const chartOptions = this.getChartOptions(); this.axisShape = this.appendChild(new g_1.Group({})); // delay 到实例被挂载到 parent 后,再渲染 chart (0, s2_1.waitForCellMounted)(() => { if (this.destroyed) { return; } // https://g2.antv.antgroup.com/manual/extra-topics/bundle#g2corelib (0, g2_1.renderToMountedElement)(chartOptions, { group: this.axisShape, library: (0, g2_1.corelib)(), }); }); } } exports.AxisRowCell = AxisRowCell; //# sourceMappingURL=axis-row-cell.js.map