Skip to content

Commit 016b062

Browse files
authored
Merge pull request #379 from Dessia-tech/chore/bug_resize
Chore/bug resize
2 parents dd5d301 + 2357d9c commit 016b062

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.22.5]
9+
### Fix
10+
- Fix global bug on RemoteFigure.resize methods, fixing a browser crasher bug
11+
812
## [0.22.4]
913
### Fix
1014
- Fix bug on tooltip origin when mouse leaving while hovering a shape

cypress/e2e/remoteFigure.cy.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ describe("RemoteFigure.resizeUpdate", function() {
147147
});
148148
});
149149

150+
describe("RemoteFigure.resizeWindow", function() {
151+
it("should resize figure with new window size", function() {
152+
const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id);
153+
figure.setCanvas(canvas.id);
154+
figure.resizeWindow(700, 500);
155+
expect(figure.size.x, "size.x").to.be.equal(700);
156+
expect(figure.size.y, "size.y").to.be.equal(500);
157+
});
158+
});
159+
150160
describe("RemoteFigure.reset", function() {
151161
it("should reset scales and selectors", function() {
152162
const figure = new RemoteFigure(data, canvas.width, canvas.height, 100, 100, canvas.id);

plot_data/templates.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@
7777
onclick="plot_data.htmlToggleAxes()"> Show / Hide Axes </button>
7878
<button name="logScale" value="OK" type="button"
7979
onclick="plot_data.switchLogScale()"> Log Scale</button>
80+
<button name="resize" value="OK" type="button"
81+
onclick="plot_data.resizeWindow(...PlotData.computeCanvasSize('#buttons'))"> Resize </button>
8082
</div>
8183
$specific_buttons
8284
</div>

src/figures.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,20 +467,16 @@ export class Scatter extends Frame {
467467
this.computePoints();
468468
}
469469

470-
public boundingBoxResize(origin: Vertex, width: number, height: number): void {
471-
super.boundingBoxResize(origin, width, height);
472-
this.computePoints();
473-
}
474-
475470
public reset(): void {
476471
super.reset();
477472
this.computePoints();
478473
this.resetClusters();
479474
}
480475

481-
public resize(): void {
482-
super.resize();
476+
public resizeUpdate(): void {
477+
this.resize();
483478
this.computePoints();
479+
this.draw();
484480
}
485481

486482
protected drawAbsoluteObjects(context: CanvasRenderingContext2D): void {
@@ -1113,10 +1109,10 @@ export class Draw extends Frame {
11131109
this.draw();
11141110
}
11151111

1116-
public resize(): void {
1117-
super.resize();
1118-
this.updateBounds();
1112+
public resizeUpdate(): void {
1113+
this.resize();
11191114
this.axisEqual();
1115+
this.draw();
11201116
}
11211117

11221118
protected unpackData(data: DataInterface): Map<string, any[]> {

src/remoteFigure.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,17 @@ export class RemoteFigure {
289289
this.height = height;
290290
}
291291

292+
public changeCanvasSize(width: number, height: number): void {
293+
const canvas = document.getElementById(this.canvasID) as HTMLCanvasElement;
294+
canvas.width = width;
295+
canvas.height = height;
296+
}
297+
298+
public resizeWindow(width: number, height: number): void {
299+
this.changeCanvasSize(width, height);
300+
this.boundingBoxResize(this.origin, width, height);
301+
}
302+
292303
public boundingBoxResize(origin: Vertex, width: number, height: number): void {
293304
this.changeLocationInCanvas(origin, width, height);
294305
this.resizeUpdate();

0 commit comments

Comments
 (0)