Skip to content

Commit 19e9583

Browse files
authored
Merge pull request #4003 from VisActor/fix/canvas-range
fix: fix node-canvas range in PivotChart #3997
2 parents 8c897cd + 9432439 commit 19e9583

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changes": [
3+
{
4+
"packageName": "@visactor/vtable",
5+
"comment": "fix: fix node-canvas range in PivotChart #3997",
6+
"type": "none"
7+
}
8+
],
9+
"packageName": "@visactor/vtable"
10+
}

packages/vtable/src/core/BaseTable.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4260,8 +4260,24 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
42604260
this.render();
42614261
const stage = this.scenegraph.stage;
42624262
if (stage) {
4263-
const contentWidth = this.tableX + this.getAllColsWidth();
4264-
const contentHeight = this.tableY + this.getAllRowsHeight();
4263+
let contentWidth = this.tableX + this.getAllColsWidth();
4264+
let contentHeight = this.tableY + this.getAllRowsHeight();
4265+
if (this.internalProps.legends) {
4266+
this.internalProps.legends.forEach(legend => {
4267+
if (legend.orient === 'right') {
4268+
contentWidth = Math.max(contentWidth, legend.legendComponent.globalAABBBounds.x2);
4269+
} else if (legend.orient === 'bottom') {
4270+
contentHeight = Math.max(contentHeight, legend.legendComponent.globalAABBBounds.y2);
4271+
}
4272+
});
4273+
}
4274+
if (this.internalProps.title) {
4275+
if (this.internalProps.title._titleOption.orient === 'right') {
4276+
contentWidth = Math.max(contentWidth, this.internalProps.title.getComponentGraphic().globalAABBBounds.x2);
4277+
} else if (this.internalProps.title._titleOption.orient === 'bottom') {
4278+
contentHeight = Math.max(contentHeight, this.internalProps.title.getComponentGraphic().globalAABBBounds.y2);
4279+
}
4280+
}
42654281
if (contentWidth >= this.canvasWidth && contentHeight >= this.canvasHeight) {
42664282
stage.render();
42674283
const buffer = stage.window.getImageBuffer(type);

0 commit comments

Comments
 (0)