From 75db3e3245cadf59eb42085e123d9f0aa1865cda Mon Sep 17 00:00:00 2001 From: wisonic Date: Mon, 4 Nov 2024 16:30:27 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E8=A1=A8=E5=90=88=E5=B9=B6=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E5=92=8C=E6=99=AE=E9=80=9A=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/table/table-info.ts | 63 ++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts index 16fe08d371..682f46f46b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-info.ts @@ -3,17 +3,18 @@ import { S2DataConfig, S2Event, S2Options, + S2Theme, TableColCell, TableDataCell, TableSheet, ViewMeta } from '@antv/s2' import { formatterItem, valueFormatter } from '../../../formatter' -import { parseJson } from '../../../util' +import { hexColorToRGBA, isAlphaColor, parseJson } from '../../../util' import { S2ChartView, S2DrawOptions } from '../../types/impl/s2' import { TABLE_EDITOR_PROPERTY, TABLE_EDITOR_PROPERTY_INNER } from './common' import { useI18n } from '@/hooks/web/useI18n' -import { isNumber } from 'lodash-es' +import { isNumber, merge } from 'lodash-es' import { copyContent, getRowIndex, @@ -330,6 +331,64 @@ export class TableInfo extends S2ChartView { return newChart } + protected configTheme(chart: Chart): S2Theme { + const theme = super.configTheme(chart) + const { basicStyle, tableCell } = parseJson(chart.customAttr) + if (tableCell.mergeCells) { + const tableFontColor = hexColorToRGBA(tableCell.tableFontColor, basicStyle.alpha) + let tableItemBgColor = tableCell.tableItemBgColor + if (!isAlphaColor(tableItemBgColor)) { + tableItemBgColor = hexColorToRGBA(tableItemBgColor, basicStyle.alpha) + } + const { tableBorderColor } = basicStyle + const { tableItemAlign, tableItemFontSize } = tableCell + const fontStyle = tableCell.isItalic ? 'italic' : 'normal' + const fontWeight = tableCell.isBolder === false ? 'normal' : 'bold' + const mergeCellTheme: S2Theme = { + mergedCell: { + cell: { + backgroundColor: tableItemBgColor, + crossBackgroundColor: tableItemBgColor, + horizontalBorderColor: tableBorderColor, + verticalBorderColor: tableBorderColor, + horizontalBorderWidth: tableCell.showHorizonBorder ? 1 : 0, + verticalBorderWidth: tableCell.showVerticalBorder ? 1 : 0 + }, + bolderText: { + fill: tableFontColor, + textAlign: tableItemAlign, + fontSize: tableItemFontSize, + fontStyle, + fontWeight + }, + text: { + fill: tableFontColor, + textAlign: tableItemAlign, + fontSize: tableItemFontSize, + fontStyle, + fontWeight + }, + measureText: { + fill: tableFontColor, + textAlign: tableItemAlign, + fontSize: tableItemFontSize, + fontStyle, + fontWeight + }, + seriesText: { + fill: tableFontColor, + textAlign: tableItemAlign, + fontSize: tableItemFontSize, + fontStyle, + fontWeight + } + } + } + merge(theme, mergeCellTheme) + } + return theme + } + constructor() { super('table-info', []) }