diff --git a/CHANGELOG.md b/CHANGELOG.md index 78ba6eaf..84a605ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Refactor - Implements InteractiveObject for handling all mouse objects in one class +## [0.22.5] +### Fix +- Fix global bug on RemoteFigure.resize methods, fixing a browser crasher bug ## [0.22.4] ### Fix diff --git a/cypress/e2e/remoteFigure.cy.ts b/cypress/e2e/remoteFigure.cy.ts index f745ab71..e1e13d6a 100644 --- a/cypress/e2e/remoteFigure.cy.ts +++ b/cypress/e2e/remoteFigure.cy.ts @@ -147,6 +147,16 @@ describe("RemoteFigure.resizeUpdate", function() { }); }); +describe("RemoteFigure.resizeWindow", function() { + it("should resize figure with new window size", function() { + const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id); + figure.setCanvas(canvas.id); + figure.resizeWindow(700, 500); + expect(figure.size.x, "size.x").to.be.equal(700); + expect(figure.size.y, "size.y").to.be.equal(500); + }); +}); + describe("RemoteFigure.reset", function() { it("should reset scales and selectors", function() { const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id); diff --git a/plot_data/templates.py b/plot_data/templates.py index a2b6536e..6b11a064 100644 --- a/plot_data/templates.py +++ b/plot_data/templates.py @@ -77,6 +77,8 @@ onclick="plot_data.htmlToggleAxes()"> Show / Hide Axes + $specific_buttons diff --git a/src/figures.ts b/src/figures.ts index c18870b4..32ddaed7 100644 --- a/src/figures.ts +++ b/src/figures.ts @@ -468,20 +468,16 @@ export class Scatter extends Frame { this.computePoints(); } - public boundingBoxResize(origin: Vertex, width: number, height: number): void { - super.boundingBoxResize(origin, width, height); - this.computePoints(); - } - public reset(): void { super.reset(); this.computePoints(); this.resetClusters(); } - public resize(): void { - super.resize(); + public resizeUpdate(): void { + this.resize(); this.computePoints(); + this.draw(); } protected drawAbsoluteObjects(context: CanvasRenderingContext2D): void { @@ -1115,10 +1111,10 @@ export class Draw extends Frame { this.draw(); } - public resize(): void { - super.resize(); - this.updateBounds(); + public resizeUpdate(): void { + this.resize(); this.axisEqual(); + this.draw(); } protected unpackData(data: DataInterface): Map { diff --git a/src/remoteFigure.ts b/src/remoteFigure.ts index 7ce9bb22..6998cff2 100644 --- a/src/remoteFigure.ts +++ b/src/remoteFigure.ts @@ -288,6 +288,17 @@ export class RemoteFigure extends Rect { this.height = height; } + public changeCanvasSize(width: number, height: number): void { + const canvas = document.getElementById(this.canvasID) as HTMLCanvasElement; + canvas.width = width; + canvas.height = height; + } + + public resizeWindow(width: number, height: number): void { + this.changeCanvasSize(width, height); + this.boundingBoxResize(this.origin, width, height); + } + public boundingBoxResize(origin: Vertex, width: number, height: number): void { this.changeLocationInCanvas(origin, width, height); this.resizeUpdate();