Skip to content

Commit

Permalink
Merge pull request #380 from Dessia-tech/chore/patch0-22
Browse files Browse the repository at this point in the history
Chore/patch0 22
  • Loading branch information
Tanguylo authored Mar 27, 2024
2 parents b768143 + 7e89e16 commit 17a95d9
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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 {
Expand Down Expand Up @@ -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<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 @@ -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();
Expand Down

0 comments on commit 17a95d9

Please sign in to comment.