From 37449f00c5b15156b2c7263be7ba1cfcfad1e623 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Thu, 10 Jan 2019 17:08:55 +0100 Subject: [PATCH] =?UTF-8?q?R=C3=A9solution=20bug=20de=20taille=20du=20canv?= =?UTF-8?q?as=20(courbes=20de=20r=C3=A9sultats)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/components/canvas/canvas.component.ts | 14 ++++++-------- .../section-canvas/section-canvas.component.ts | 12 ++++++------ .../section-results/section-results.component.ts | 8 ++++---- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/app/components/canvas/canvas.component.ts b/src/app/components/canvas/canvas.component.ts index 78836a4d3..87f03401c 100644 --- a/src/app/components/canvas/canvas.component.ts +++ b/src/app/components/canvas/canvas.component.ts @@ -3,8 +3,8 @@ import { Component, Input, ViewChild, ElementRef, AfterViewInit } from "@angular @Component({ selector: "calc-canvas", template: `<canvas #canvas - [attr.width] = 'width' - [attr.height] = 'height'> + [attr.width]="width" + [attr.height]="height"> </canvas> ` }) @@ -19,19 +19,17 @@ export class CalcCanvasComponent implements AfterViewInit { @Input() public set width(w: number) { this._width = w; + this._calcCanvas.nativeElement.width = w; } public get height(): number { return this._calcCanvas.nativeElement.height; } - public get witdh() { - return this._width; - } - @Input() public set height(h: number) { this._height = h; + this._calcCanvas.nativeElement.height = h; } private _context2d: CanvasRenderingContext2D; @@ -49,7 +47,7 @@ export class CalcCanvasComponent implements AfterViewInit { } public clear() { - if (this._context2d != undefined) { + if (this._context2d) { this._context2d.clearRect(0, 0, this.width, this.height); } } @@ -69,7 +67,7 @@ export class CalcCanvasComponent implements AfterViewInit { } public fillText(s: string, x: number, y: number, align?: any) { - if (align != undefined) { + if (align) { this._context2d.textAlign = align; } this._context2d.fillText(s, x, y); diff --git a/src/app/components/section-canvas/section-canvas.component.ts b/src/app/components/section-canvas/section-canvas.component.ts index 5323ded5f..68187ba48 100644 --- a/src/app/components/section-canvas/section-canvas.component.ts +++ b/src/app/components/section-canvas/section-canvas.component.ts @@ -10,8 +10,8 @@ import { CalcCanvasComponent } from "../canvas/canvas.component"; @Component({ selector: "section-canvas", template: `<calc-canvas #calcCanvas - [width] = 'size' - [height] = 'size'> + [width]="size" + [height]="size"> </calc-canvas> ` }) @@ -47,7 +47,7 @@ export class SectionCanvasComponent { public set section(s: acSection) { this._section = s; - if (this._section != undefined) { + if (this._section) { this.draw(); } } @@ -219,8 +219,8 @@ export class SectionCanvasComponent { return maxWidth; } catch (e) { - const r: Result = e as Result; - this.drawText("error : " + r.log.toString(), 0, 0); + const res: Result = e as Result; + this.drawText("error : " + res.log.toString(), 0, 0); } } @@ -281,7 +281,7 @@ export class SectionCanvasComponent { this._calcCanvas.drawEllipse(this.Xm2pix(x), this.Ym2pix(y), rX * this._scaleX, rY * this._scaleY, rot, start, end); } - private drawText(s: string, x: number, y: number, align: string = undefined) { + private drawText(s: string, x: number, y: number, align?: string) { this._calcCanvas.fillText(s, this.Xm2pix(x), this.Ym2pix(y), align); } diff --git a/src/app/components/section-results/section-results.component.ts b/src/app/components/section-results/section-results.component.ts index 96854ef9b..965475284 100644 --- a/src/app/components/section-results/section-results.component.ts +++ b/src/app/components/section-results/section-results.component.ts @@ -40,7 +40,7 @@ export class SectionResultsComponent implements DoCheck { this._resultElement = undefined; this._results = undefined; - if (rs != undefined) { + if (rs) { for (const r of rs) { if (r instanceof SectionResults) { this._results = r; @@ -52,7 +52,7 @@ export class SectionResultsComponent implements DoCheck { } public get hasResults(): boolean { - return this._results != undefined && this._results.hasResults; + return this._results && this._results.hasResults; } private get resultElement() { @@ -84,11 +84,11 @@ export class SectionResultsComponent implements DoCheck { private _sectionCanvas: SectionCanvasComponent; public updateView() { - if (this._sectionCanvas != undefined) { + if (this._sectionCanvas) { this._sectionCanvas.reset(); } - if (this._results != undefined) { + if (this._results) { this._doUpdate = this._results.hasResults; } } -- GitLab