@antv/s2
Version:
effective spreadsheet render core lib
82 lines • 3.17 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AxisColCell = 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 AxisColCell extends s2_1.ColCell {
get cellType() {
return cell_type_1.AxisCellType.AXIS_COL_CELL;
}
getBorderPositions() {
return [
s2_1.CellBorderPosition.TOP,
s2_1.CellBorderPosition.BOTTOM,
s2_1.CellBorderPosition.RIGHT,
];
}
isBolderText() {
return false;
}
getInteractedCells() {
var _a;
return (_a = this.spreadsheet.interaction) === null || _a === void 0 ? void 0 : _a.getCells([
s2_1.CellType.COL_CELL,
cell_type_1.AxisCellType.AXIS_COL_CELL,
]);
}
initCell() {
this.drawBackgroundShape();
this.drawInteractiveBgShape();
this.drawInteractiveBorderShape();
this.drawTextShape();
this.drawBorders();
this.drawResizeArea();
this.update();
}
getColResizeArea() {
return (0, s2_1.getOrCreateResizeAreaGroupById)(this.spreadsheet, constant_1.KEY_GROUP_COL_AXIS_RESIZE_AREA);
}
isCrossColumnLeafNode() {
return false;
}
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.axisColCellSpec;
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.getAxisYOptions)(this.meta, this.spreadsheet)
: (0, chart_options_1.getAxisXOptions)(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.AxisColCell = AxisColCell;
//# sourceMappingURL=axis-col-cell.js.map