Skip to content

Commit 17a95d9

Browse files
authored
Merge pull request #380 from Dessia-tech/chore/patch0-22
Chore/patch0 22
2 parents b768143 + 7e89e16 commit 17a95d9

File tree

5 files changed

+32
-10
lines changed

5 files changed

+32
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323

2424
### Refactor
2525
- Implements InteractiveObject for handling all mouse objects in one class
26+
## [0.22.5]
27+
### Fix
28+
- Fix global bug on RemoteFigure.resize methods, fixing a browser crasher bug
2629

2730
## [0.22.4]
2831
### Fix

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
@@ -468,20 +468,16 @@ export class Scatter extends Frame {
468468
this.computePoints();
469469
}
470470

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

482-
public resize(): void {
483-
super.resize();
477+
public resizeUpdate(): void {
478+
this.resize();
484479
this.computePoints();
480+
this.draw();
485481
}
486482

487483
protected drawAbsoluteObjects(context: CanvasRenderingContext2D): void {
@@ -1115,10 +1111,10 @@ export class Draw extends Frame {
11151111
this.draw();
11161112
}
11171113

1118-
public resize(): void {
1119-
super.resize();
1120-
this.updateBounds();
1114+
public resizeUpdate(): void {
1115+
this.resize();
11211116
this.axisEqual();
1117+
this.draw();
11221118
}
11231119

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

src/remoteFigure.ts

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

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

0 commit comments

Comments
 (0)