UNPKG

@antv/s2

Version:

effective spreadsheet render core lib

44 lines 1.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChartDataCell = void 0; const g_lite_1 = require("@antv/g-lite"); const g2_1 = require("@antv/g2"); const s2_1 = require("@antv/s2"); const lodash_1 = require("lodash"); const chart_options_1 = require("../utils/chart-options"); class ChartDataCell extends s2_1.DataCell { drawTextShape() { // 普通数值单元格正常展示 if (!this.isChartData()) { super.drawTextShape(); return; } this.chartShape = this.appendChild(new g_lite_1.Group({ style: { zIndex: 1 } })); const chartOptions = this.getChartOptions(); (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.chartShape, library: (0, g2_1.corelib)(), }); }); } isChartData() { const fieldValue = this.getFieldValue(); return (0, lodash_1.isPlainObject)(fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.values); } getChartData() { const { fieldValue } = this.meta; return fieldValue === null || fieldValue === void 0 ? void 0 : fieldValue.values; } getChartOptions() { const chartData = this.getChartData(); const cellArea = this.getBBoxByType(s2_1.CellClipBox.CONTENT_BOX); return Object.assign(Object.assign(Object.assign({ autoFit: true }, (0, chart_options_1.getTheme)(this.spreadsheet)), cellArea), chartData); } } exports.ChartDataCell = ChartDataCell; //# sourceMappingURL=chart-data-cell.js.map