From ed1d1dd77e05cafd66a5a0c938c33e238fffc7d3 Mon Sep 17 00:00:00 2001 From: ulleo Date: Thu, 22 Jan 2026 17:29:44 +0800 Subject: [PATCH] feat: improve long text display in table chart --- .../src/views/chat/component/charts/Table.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/frontend/src/views/chat/component/charts/Table.ts b/frontend/src/views/chat/component/charts/Table.ts index 1ca46f4c..a883d6d2 100644 --- a/frontend/src/views/chat/component/charts/Table.ts +++ b/frontend/src/views/chat/component/charts/Table.ts @@ -8,6 +8,7 @@ import { type S2MountContainer, type SortMethod, type Node, + type CellTextWordWrapStyle, } from '@antv/s2' import { debounce, filter } from 'lodash-es' import { i18n } from '@/i18n' @@ -70,6 +71,15 @@ export class Table extends BaseChart { data: this.data, } + const cellTextWordWrapStyle: CellTextWordWrapStyle = { + // 最大行数,文本超出后将被截断 + maxLines: 3, + // 文本是否换行 + wordWrap: true, + // 可选项见:https://g.antv.antgroup.com/api/basic/text#textoverflow + textOverflow: 'ellipsis', + } + const s2Options: S2Options = { width: 600, height: 360, @@ -146,6 +156,24 @@ export class Table extends BaseChart { }, }, }, + // 如果有省略号, 复制到的是完整文本 + interaction: { + copy: { + enable: true, + withFormat: true, + withHeader: true, + }, + brushSelection: { + dataCell: true, + rowCell: true, + colCell: true, + }, + }, + style: { + colCell: cellTextWordWrapStyle, + // 如果是数值不建议换行, 容易产生歧义 + dataCell: cellTextWordWrapStyle, + }, placeholder: { cell: '-', empty: {