Skip to content

Commit

Permalink
fix: use default style in exportCellImg()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Mar 19, 2024
1 parent 97c3d07 commit 35ab76a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "fix: use default style in exportCellImg()",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
16 changes: 16 additions & 0 deletions packages/vtable/src/core/BaseTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import { setBatchRenderChartCount } from '../scenegraph/graphic/contributions/ch
import { isLeftOrRightAxis, isTopOrBottomAxis } from '../layout/chart-helper/get-axis-config';
import { NumberRangeMap } from '../layout/row-height-map';
import { CustomCellStylePlugin, mergeStyle } from '../plugins/custom-cell-style';
import { hideCellSelectBorder, restoreCellSelectBorder } from '../scenegraph/select/update-select-border';
const { toBoxArray } = utilStyle;
const { isTouchEvent } = event;
const rangeReg = /^\$(\d+)\$(\d+)$/;
Expand Down Expand Up @@ -3690,6 +3691,14 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
this.scrollToCell({ col, row });
}
const cellRect = this.getCellRelativeRect(col, row);

// disable hover&select style
if (this.stateManager.select?.ranges?.length > 0) {
hideCellSelectBorder(this.scenegraph);
}
const { col: hoverCol, row: hoverRow } = this.stateManager.hover.cellPos;
this.stateManager.updateHoverPos(-1, -1);

const c = this.scenegraph.stage.toCanvas(
false,
new AABBBounds().set(
Expand All @@ -3704,6 +3713,13 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
this.setScrollLeft(scrollLeft);
}
// return c.toDataURL('image/jpeg', 0.5);

// restore hover&select style
if (this.stateManager.select?.ranges?.length > 0) {
restoreCellSelectBorder(this.scenegraph);
}
this.stateManager.updateHoverPos(hoverCol, hoverRow);

return c.toDataURL();
}

Expand Down
18 changes: 18 additions & 0 deletions packages/vtable/src/scenegraph/select/update-select-border.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,3 +544,21 @@ export function updateCellSelectBorder(
);
}
}

export function hideCellSelectBorder(scene: Scenegraph) {
scene.selectingRangeComponents.forEach((selectComp: { rect: IRect; role: CellSubLocation }, key: string) => {
selectComp.rect.setAttribute('visible', false);
});
scene.selectedRangeComponents.forEach((selectComp: { rect: IRect; role: CellSubLocation }, key: string) => {
selectComp.rect.setAttribute('visible', false);
});
}

export function restoreCellSelectBorder(scene: Scenegraph) {
scene.selectingRangeComponents.forEach((selectComp: { rect: IRect; role: CellSubLocation }, key: string) => {
selectComp.rect.setAttribute('visible', false);
});
scene.selectedRangeComponents.forEach((selectComp: { rect: IRect; role: CellSubLocation }, key: string) => {
selectComp.rect.setAttribute('visible', false);
});
}

0 comments on commit 35ab76a

Please sign in to comment.