Skip to content

Commit

Permalink
Merge pull request #379 from Dessia-tech/chore/bug_resize
Browse files Browse the repository at this point in the history
Chore/bug resize
  • Loading branch information
Tanguylo authored Mar 27, 2024
2 parents dd5d301 + 2357d9c commit 016b062
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.22.5]
### Fix
- Fix global bug on RemoteFigure.resize methods, fixing a browser crasher bug

## [0.22.4]
### Fix
- Fix bug on tooltip origin when mouse leaving while hovering a shape
Expand Down
10 changes: 10 additions & 0 deletions cypress/e2e/remoteFigure.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions plot_data/templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@
onclick="plot_data.htmlToggleAxes()"> Show / Hide Axes </button>
<button name="logScale" value="OK" type="button"
onclick="plot_data.switchLogScale()"> Log Scale</button>
<button name="resize" value="OK" type="button"
onclick="plot_data.resizeWindow(...PlotData.computeCanvasSize('#buttons'))"> Resize </button>
</div>
$specific_buttons
</div>
Expand Down
16 changes: 6 additions & 10 deletions src/figures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,20 +467,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 {
Expand Down Expand Up @@ -1113,10 +1109,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<string, any[]> {
Expand Down
11 changes: 11 additions & 0 deletions src/remoteFigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,17 @@ export class RemoteFigure {
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();
Expand Down

0 comments on commit 016b062

Please sign in to comment.