From b4eb6e0b0aee715cc07d30b43a93199f9c6b4d83 Mon Sep 17 00:00:00 2001 From: Tao Date: Mon, 27 Jul 2026 22:30:22 -0700 Subject: [PATCH] fix(xlsx): clip anchored charts/images/drawings to the grid's freeze panes The chart, image, and drawing layers spanned the whole sheet surface with no clipping, so anchored objects scrolled past the grid origin painted over the column/row headers, the formula bar, and the host UI around the viewer. Each layer also carried its own copy of the frozen-extent, anchor-rect, and scroll-compensation math. Consolidate the geometry in grid-metrics.ts: createGridPaneLayout() derives the freeze-pane sub-boxes (main / frozen-rows / frozen-cols / frozen-corner) inside a grid-body layer inset past the headers, and places each object in the pane owning its anchor origin, compensating scroll only on the scrolling axes. The three layers become thin views that group items by pane; each pane clips its own objects the way Excel clips drawings per pane, with frozen panes stacked above the main pane to match the canvas paint order. Also align the public GRID_ROW_HEADER_WIDTH constant (40 -> 48) with the gutter XlsxGrid actually paints, so setChartRect/getChartRect coordinates agree with on-screen geometry; internal.ts is now the single source for both header metrics. Co-Authored-By: Claude Opus 5 (1M context) --- .../src/components/XlsxChartOverlay.vue | 124 ++++++++-------- .../src/components/XlsxDrawingLayer.vue | 117 +++++++++------- packages/vue-xlsx/src/components/XlsxGrid.vue | 5 +- .../src/components/XlsxImageLayer.vue | 118 ++++++++-------- .../vue-xlsx/src/components/grid-metrics.ts | 132 ++++++++++++++++++ packages/vue-xlsx/src/composables/internal.ts | 4 +- tests/component/xlsx-anchored-panes.test.mjs | 86 ++++++++++++ 7 files changed, 408 insertions(+), 178 deletions(-) create mode 100644 packages/vue-xlsx/src/components/grid-metrics.ts create mode 100644 tests/component/xlsx-anchored-panes.test.mjs diff --git a/packages/vue-xlsx/src/components/XlsxChartOverlay.vue b/packages/vue-xlsx/src/components/XlsxChartOverlay.vue index 4847219..74a35fc 100644 --- a/packages/vue-xlsx/src/components/XlsxChartOverlay.vue +++ b/packages/vue-xlsx/src/components/XlsxChartOverlay.vue @@ -4,35 +4,44 @@ data-testid="xlsx-chart-overlay" :data-state="controller.isChartsLoading ? 'loading' : 'ready'" :data-chart-count="chartItems.length" + :style="layerStyle" >
- -
- 📊 不支持的图表类型 +
+ +
+ 📊 不支持的图表类型 +
@@ -40,9 +49,9 @@