From 286844e1d10f552cb6ad1c3bb9ba62247043f702 Mon Sep 17 00:00:00 2001 From: wisonic Date: Fri, 1 Nov 2024 12:12:48 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=9B=BE=E8=A1=A8):=20=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E8=A1=A8=E5=90=88=E5=B9=B6=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/common/common_table.ts | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts index 7467873b81..d1d7985f77 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_table.ts @@ -29,7 +29,10 @@ import { InteractionStateName, InteractionName, DataCellBrushSelection, - TableDataCell + TableDataCell, + MergedCell, + getPolygonPoints, + renderPolygon } from '@antv/s2' import { keys, intersection, filter, cloneDeep, merge, find, repeat } from 'lodash-es' import { createVNode, render } from 'vue' @@ -1462,5 +1465,25 @@ export function configMergeCells(chart: Chart, options: S2Options) { }) }) options.mergedCellsInfo = mergedCellsInfo + options.mergedCell = (sheet, cells, meta) => { + return new CustomMergedCell(sheet, cells, meta) + } } } + +class CustomMergedCell extends MergedCell { + protected drawBackgroundShape() { + const allPoints = getPolygonPoints(this.cells) + // 处理条件样式,这里没有用透明度 + // 因为合并的单元格是单独的图层,透明度降低的话会显示底下未合并的单元格,需要单独处理被覆盖的单元格 + const { backgroundColor: fill, backgroundColorOpacity: fillOpacity } = + this.getBackgroundColor(); + const cellTheme = this.theme.dataCell.cell + this.backgroundShape = renderPolygon(this, { + points: allPoints, + stroke: cellTheme.horizontalBorderColor, + fill, + lineHeight: cellTheme.horizontalBorderWidth, + }) + } +} \ No newline at end of file