From 8eda25115469a4701b33d42f5a0d642410f2a273 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Wed, 3 Sep 2025 16:21:47 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=A1=A8=E6=A0=BC=E8=87=AA=E9=80=82=E5=BA=94=E6=A8=A1=E5=BC=8F?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=A8=AA=E5=90=91=E6=BB=9A=E5=8A=A8=E6=9D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/js/panel/charts/table/table-info.ts | 8 ++++---- .../components/js/panel/charts/table/table-normal.ts | 10 +++++----- 2 files changed, 9 insertions(+), 9 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 eb339117be..ceda44174a 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 @@ -181,7 +181,7 @@ export class TableInfo extends S2ChartView { // options const s2Options: S2Options = { - width: containerDom.offsetWidth, + width: containerDom.getBoundingClientRect().width, height: containerDom.offsetHeight, seriesNumber: { enable: tableHeader.showIndex, @@ -297,7 +297,7 @@ export class TableInfo extends S2ChartView { const totalWidthWithImg = ev.colLeafNodes.reduce((p, n) => { return p + (urlFields.includes(n.field) ? 120 : n.width) }, 0) - const containerWidth = containerDom.offsetWidth + const containerWidth = containerDom.getBoundingClientRect().width - 1 if (containerWidth <= totalWidthWithImg) { // 图库计算的布局宽度已经大于等于容器宽度,不需要再扩大,但是需要处理非整数宽度值,不然会出现透明细线 ev.colLeafNodes.reduce((p, n) => { @@ -325,11 +325,11 @@ export class TableInfo extends S2ChartView { n.x = getStartPosition(n) } }) + const lastNode = ev.colLeafNodes[ev.colLeafNodes.length - 1] if (totalWidth > containerWidth) { - const lastNode = ev.colLeafNodes[ev.colLeafNodes.length - 1] lastNode.width = Math.floor(lastNode.width - (totalWidth - containerWidth)) } - ev.colsHierarchy.width = containerWidth - 2 + ev.colsHierarchy.width = lastNode.x + lastNode.width }) } // 空数据时表格样式 diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts index 3ce5571741..ef8ada4de1 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/table/table-normal.ts @@ -140,7 +140,7 @@ export class TableNormal extends S2ChartView { const { basicStyle, tableCell, tableHeader, tooltip } = parseJson(chart.customAttr) // options const s2Options: S2Options = { - width: containerDom.offsetWidth, + width: containerDom.getBoundingClientRect().width, height: containerDom.offsetHeight, seriesNumber: { enable: tableHeader.showIndex, @@ -216,7 +216,7 @@ export class TableNormal extends S2ChartView { newChart.store.set('lastLayoutResult', undefined) return } - const containerWidth = containerDom.offsetWidth + const containerWidth = containerDom.getBoundingClientRect().width - 1 const scale = containerWidth / ev.colsHierarchy.width if (scale <= 1) { // 图库计算的布局宽度已经大于等于容器宽度,不需要再扩大,但是需要处理非整数宽度值,不然会出现透明细线 @@ -232,12 +232,12 @@ export class TableNormal extends S2ChartView { n.x = p return p + n.width }, 0) + // 从最后一列减掉 + const lastNode = ev.colLeafNodes[ev.colLeafNodes.length - 1] if (totalWidth > containerWidth) { - // 从最后一列减掉 - const lastNode = ev.colLeafNodes[ev.colLeafNodes.length - 1] lastNode.width = Math.floor(lastNode.width - (totalWidth - containerWidth)) } - ev.colsHierarchy.width = containerWidth - 1 + ev.colsHierarchy.width = lastNode.x + lastNode.width }) } configEmptyDataStyle(newChart, basicStyle, newData, container)