From b1951aa945f4b28c5a3b0dfe0c8652ad95f850c9 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Fri, 17 Jul 2020 14:18:33 +0200
Subject: [PATCH 01/12] Use TypeScript's "Optional Chaining" syntax

---
 src/app/components/log/log.component.ts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/app/components/log/log.component.ts b/src/app/components/log/log.component.ts
index 350e544fe..18da5657c 100644
--- a/src/app/components/log/log.component.ts
+++ b/src/app/components/log/log.component.ts
@@ -34,7 +34,7 @@ export class LogComponent {
     }
 
     public get hasEntries(): boolean {
-        return this._log?.messages?.length > 0;
+        return this._log?.messages?.length !== 0;
     }
 
     public get messages(): Message[] {
-- 
GitLab


From 1c99db48f2944b7ebd84b5da0056a61fd2b3132b Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Thu, 16 Jul 2020 16:10:47 +0200
Subject: [PATCH 02/12] Fix #418 - use proper Angular mechanisms in results
 components

---
 .../calculator-results.component.html         |  14 +-
 .../calculator-results.component.ts           | 142 ++------------
 .../fixed-results.component.ts                |   3 +-
 .../fixedvar-results.component.html           |   4 +-
 .../fixedvar-results.component.ts             | 105 +---------
 .../fixedvar-results/var-results.component.ts |   3 +-
 .../jet-results/jet-results.component.html    |   4 +-
 .../jet-results/jet-results.component.ts      |  43 +----
 .../jet-trajectory-chart.component.ts         |   5 +-
 src/app/components/log/log.component.html     |   2 +-
 src/app/components/log/log.component.ts       |  13 +-
 ...rorugo-compound-results-table.component.ts |  37 ++--
 .../macrorugo-compound-results.component.html |  11 +-
 .../macrorugo-compound-results.component.ts   | 114 +----------
 .../pab-profile-chart.component.ts            |   3 +-
 .../pab-results-table.component.ts            |  57 +++---
 .../pab-results/pab-results.component.html    |  14 +-
 .../pab-results/pab-results.component.ts      | 123 +-----------
 .../pb-cloison-results.component.ts           |   3 +-
 .../pb-results/pb-results-table.component.ts  |   3 +-
 .../pb-results/pb-results.component.html      |  10 +-
 .../pb-results/pb-results.component.ts        | 181 +-----------------
 .../remous-results.component.html             |   6 +-
 .../remous-results.component.ts               |  84 +++-----
 .../results-chart/results-chart.component.ts  |   8 +-
 .../section-results.component.ts              |  25 +--
 .../variable-results-selector.component.ts    |  55 +++---
 src/app/results/multidimension-results.ts     |   2 +-
 src/app/results/var-results.ts                |   6 +-
 29 files changed, 228 insertions(+), 852 deletions(-)

diff --git a/src/app/components/calculator-results/calculator-results.component.html b/src/app/components/calculator-results/calculator-results.component.html
index 4befd3308..7f8019197 100644
--- a/src/app/components/calculator-results/calculator-results.component.html
+++ b/src/app/components/calculator-results/calculator-results.component.html
@@ -1,10 +1,10 @@
 <div>
-    <section-results [hidden]="! isSP"></section-results>
-    <remous-results [hidden]="! isRemous"></remous-results>
-    <pab-results [hidden]="! isPAB"></pab-results>
-    <pb-results [hidden]="! isPB"></pb-results>
+    <section-results [hidden]="! isSP" [results]=formResultsArray></section-results>
+    <remous-results [hidden]="! isRemous" [results]=formResultsArray></remous-results>
+    <pab-results [hidden]="! isPAB" [results]=formResultsArray></pab-results>
+    <pb-results [hidden]="! isPB" [results]=formResultsArray></pb-results>
     <verificateur-results [hidden]="! isVerificateur"></verificateur-results>
-    <macrorugo-compound-results [hidden]="! isMRC"></macrorugo-compound-results>
-    <jet-results [hidden]="! isJet"></jet-results>
-    <fixedvar-results [hidden]="! showGenericResults"></fixedvar-results>
+    <macrorugo-compound-results [hidden]="! isMRC" [results]=formResultsArray></macrorugo-compound-results>
+    <jet-results *ngIf="isJet" [results]=formResultsArray></jet-results>
+    <fixedvar-results *ngIf="! isJet" [results]=formResultsArray></fixedvar-results>
 </div>
diff --git a/src/app/components/calculator-results/calculator-results.component.ts b/src/app/components/calculator-results/calculator-results.component.ts
index 8c36c651c..27fa0e724 100644
--- a/src/app/components/calculator-results/calculator-results.component.ts
+++ b/src/app/components/calculator-results/calculator-results.component.ts
@@ -1,17 +1,8 @@
-import { Component, ViewChild, Output, EventEmitter, AfterViewChecked, Inject, forwardRef } from "@angular/core";
+import { Component, Output, EventEmitter, AfterViewChecked, Inject, forwardRef } from "@angular/core";
 
-import { FixedVarResultsComponent } from "../../components/fixedvar-results/fixedvar-results.component";
-import { SectionResultsComponent } from "../../components/section-results/section-results.component";
-import { RemousResultsComponent } from "../../components/remous-results/remous-results.component";
-import { PabResultsComponent } from "../../components/pab-results/pab-results.component";
-import { MacrorugoCompoundResultsComponent } from "../macrorugo-compound-results/macrorugo-compound-results.component";
 import { FormulaireDefinition } from "../../formulaire/definition/form-definition";
-import { JetResultsComponent } from "../jet-results/jet-results.component";
+import { CalculatorResults } from "../../results/calculator-results";
 import { GenericCalculatorComponent } from "../generic-calculator/calculator.component";
-import { VerificateurResultsComponent } from "../verificateur-results/verificateur-results.component";
-
-import { CalculatorType } from "jalhyd";
-import { PbResultsComponent } from "../pb-results/pb-results.component";
 
 @Component({
     selector: "calc-results",
@@ -21,57 +12,7 @@ export class CalculatorResultsComponent implements AfterViewChecked {
 
     private _formulaire: FormulaireDefinition;
 
-    /**
-     * composant d'affichage des résultats de paramètres fixés/variables
-     */
-    @ViewChild(FixedVarResultsComponent, { static: true })
-    private fixedVarResultsComponent: FixedVarResultsComponent;
-
-    /**
-     * composant d'affichage des résultats des sections paramétrées
-     */
-    @ViewChild(SectionResultsComponent, { static: true })
-    private sectionResultsComponent: SectionResultsComponent;
-
-    /**
-     * composant d'affichage des résultats des courbes de remous
-     */
-    @ViewChild(RemousResultsComponent, { static: true })
-    private remousResultsComponent: RemousResultsComponent;
-
-    /**
-     * composant d'affichage des résultats des passes à bassins
-     */
-    @ViewChild(PabResultsComponent, { static: true })
-    private pabResultsComponent: PabResultsComponent;
-
-    /**
-     * composant d'affichage des résultats des vérificateurs de critères de franchissement
-     */
-    @ViewChild(VerificateurResultsComponent, { static: true })
-    private verificateurResultsComponent: VerificateurResultsComponent;
-
-    /*
-     * composant d'affichage des résultats des prébarrages
-     */
-    @ViewChild(PbResultsComponent, { static: true })
-    private pbResultsComponent: PbResultsComponent;
-
-    /**
-     * composant d'affichage des résultats des passes à macrorugosités complexes
-     */
-    @ViewChild(MacrorugoCompoundResultsComponent, { static: true })
-    private mrcResultsComponent: MacrorugoCompoundResultsComponent;
-
-    /**
-     * composant d'affichage des résultats des impacts de jet
-     */
-    @ViewChild(JetResultsComponent, { static: true })
-    private jetResultsComponent: JetResultsComponent;
-
-    /**
-     * événement émis à la fin du dessin de la vue
-     */
+    /** notify CalculatorComponent that it may scroll down to results panel */
     @Output()
     private afterViewChecked = new EventEmitter();
 
@@ -82,83 +23,28 @@ export class CalculatorResultsComponent implements AfterViewChecked {
     // @TODO this system is sh*tty !
     public set formulaire(f: FormulaireDefinition) {
         this._formulaire = f;
-        if (this._formulaire === undefined) {
-            this.fixedVarResultsComponent.results = undefined;
-            this.sectionResultsComponent.results = undefined;
-            this.pbResultsComponent.results = undefined;
-            this.jetResultsComponent.results = undefined;
-            this.mrcResultsComponent.results = undefined;
-            this.pabResultsComponent.results = undefined;
-            this.remousResultsComponent.results = undefined;
-            this.verificateurResultsComponent.results = undefined;
-        } else {
-            this.sectionResultsComponent.results = f.results;
-            this.remousResultsComponent.results = f.results;
-            this.pabResultsComponent.results = f.results;
-            this.pbResultsComponent.results = f.results;
-            this.mrcResultsComponent.results = f.results;
-            // FixedVar and Jet are mutually incompatible (the 2nd extend the 1st)
-            if (this.isJet) {
-                this.jetResultsComponent.results = f.results;
-                this.fixedVarResultsComponent.results = undefined;
-            } else {
-                this.fixedVarResultsComponent.results = f.results;
-                this.jetResultsComponent.results = undefined;
-            }
+    }
+
+    public get formResultsArray(): CalculatorResults[] {
+        let r: CalculatorResults[] = [];
+        if (this._formulaire !== undefined) {
+            r = this._formulaire.results;
         }
+        return r;
     }
 
     public updateView() {
-        this.fixedVarResultsComponent.updateView();
-        this.sectionResultsComponent.updateView();
-        this.remousResultsComponent.updateView();
-        this.pabResultsComponent.updateView();
-        this.pbResultsComponent.updateView();
-        this.mrcResultsComponent.updateView();
-        this.jetResultsComponent.updateView();
+        console.log("UPDATE VIEW (disabled)");
     }
 
     public ngAfterViewChecked() {
         this.afterViewChecked.emit();
     }
 
-    /** Should we show the default FixedVarResultsComponent ? */
-    public get showGenericResults(): boolean {
-        return (
-            ! this.isJet
-            && ! this.isMRC
-            && ! this.isPAB
-            && ! this.isRemous
-            && ! this.isSP
-            && ! this.isVerificateur
-        );
-    }
-
-    public get isJet(): boolean {
+    // JetResultsComponent extends FixedVarResultsComponent, which makes
+    // them incompatible with each other
+    public get isJet() {
         return this.calculatorComponent.isJet;
     }
 
-    public get isMRC(): boolean {
-        return this.calculatorComponent.isMRC;
-    }
-
-    public get isPAB(): boolean {
-        return this.calculatorComponent.isPAB;
-    }
-
-    public get isPB(): boolean {
-        return this.calculatorComponent.is(CalculatorType.PreBarrage);
-    }
-
-    public get isRemous(): boolean {
-        return this.calculatorComponent.is(CalculatorType.CourbeRemous);
-    }
-
-    public get isSP(): boolean {
-        return this.calculatorComponent.is(CalculatorType.SectionParametree);
-    }
-
-    public get isVerificateur(): boolean {
-        return this.calculatorComponent.is(CalculatorType.Verificateur);
-    }
 }
diff --git a/src/app/components/fixedvar-results/fixed-results.component.ts b/src/app/components/fixedvar-results/fixed-results.component.ts
index 8477e6cef..090c1829d 100644
--- a/src/app/components/fixedvar-results/fixed-results.component.ts
+++ b/src/app/components/fixedvar-results/fixed-results.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, ElementRef } from "@angular/core";
+import { Component, ViewChild, ElementRef, Input } from "@angular/core";
 
 import { FixedResults } from "../../results/fixed-results";
 import { I18nService } from "../../services/internationalisation.service";
@@ -35,6 +35,7 @@ export class FixedResultsComponent extends ResultsComponentDirective {
         super();
     }
 
+    @Input()
     public set results(r: FixedResults) {
         this._fixedResults = r;
     }
diff --git a/src/app/components/fixedvar-results/fixedvar-results.component.html b/src/app/components/fixedvar-results/fixedvar-results.component.html
index 7676b0268..6c2d779be 100644
--- a/src/app/components/fixedvar-results/fixedvar-results.component.html
+++ b/src/app/components/fixedvar-results/fixedvar-results.component.html
@@ -1,8 +1,8 @@
 <div class="container">
     <!-- journal -->
-    <log></log>
+    <log [log]=mergedGlobalLogs></log>
 
-    <results-chart [hidden]="! showVarResultsChart"></results-chart>
+    <results-chart [hidden]="! showVarResultsChart" [results]=varResults></results-chart>
 
     <div>
         <!-- table des résultats fixés -->
diff --git a/src/app/components/fixedvar-results/fixedvar-results.component.ts b/src/app/components/fixedvar-results/fixedvar-results.component.ts
index 04136deb5..b80300bad 100644
--- a/src/app/components/fixedvar-results/fixedvar-results.component.ts
+++ b/src/app/components/fixedvar-results/fixedvar-results.component.ts
@@ -1,14 +1,9 @@
-import { Component, ViewChild, DoCheck } from "@angular/core";
+import { Component, Input } from "@angular/core";
 
-import { LogComponent } from "../../components/log/log.component";
 import { FixedResults } from "../../results/fixed-results";
 import { VarResults } from "../../results/var-results";
-import { ResultsChartComponent } from "../results-chart/results-chart.component";
 import { CalculatorResults } from "../../results/calculator-results";
 import { Result, cLog } from "jalhyd";
-import { NgParameter } from "../../formulaire/elements/ngparam";
-import { FixedResultsComponent } from "./fixed-results.component";
-import { VarResultsComponent } from "./var-results.component";
 import { ResultsComponentDirective } from "./results.component";
 
 @Component({
@@ -18,36 +13,14 @@ import { ResultsComponentDirective } from "./results.component";
         "./fixedvar-results.component.scss"
     ]
 })
-export class FixedVarResultsComponent extends ResultsComponentDirective implements DoCheck {
+export class FixedVarResultsComponent extends ResultsComponentDirective {
     /**
      * résultats non mis en forme
      */
     protected _fixedResults: FixedResults;
     protected _varResults: VarResults;
 
-    /**
-     * true si les résultats doiventt être remis à jour
-     */
-    protected _doUpdate = false;
-
-    @ViewChild(FixedResultsComponent)
-    private fixedResultsComponent: FixedResultsComponent;
-
-    @ViewChild(VarResultsComponent)
-    private varResultsComponent: VarResultsComponent;
-
-    /**
-     * composant journal
-     */
-    @ViewChild(LogComponent)
-    private logComponent: LogComponent;
-
-    /**
-     * graphique dans le cas d'un paramètre à varier
-     */
-    @ViewChild(ResultsChartComponent)
-    private resultsChartComponent: ResultsChartComponent;
-
+    @Input()
     public set results(rs: CalculatorResults[]) {
         this._fixedResults = undefined;
         this._varResults = undefined;
@@ -60,40 +33,6 @@ export class FixedVarResultsComponent extends ResultsComponentDirective implemen
                 }
             }
         }
-        this.updateView();
-    }
-
-    public updateView() {
-        if (this.logComponent) {
-            this.logComponent.log = undefined;
-        }
-        if (this.fixedResultsComponent) {
-            this.fixedResultsComponent.results = undefined;
-        }
-        if (this.varResultsComponent) {
-            this.varResultsComponent.results = undefined;
-        }
-        if (this.resultsChartComponent) {
-            this.resultsChartComponent.results = undefined;
-        }
-
-        // set _doUpdate flag so that results are rebuilt on the next Angular display cycle
-        this._doUpdate = false;
-        if (this._fixedResults !== undefined) {
-            this._doUpdate = this._fixedResults.hasResults || this._fixedResults.hasLog;
-        }
-        if (this._varResults !== undefined) {
-            this._doUpdate = this._doUpdate || this._varResults.hasResults || this._varResults.hasLog;
-        }
-    }
-
-    public ngDoCheck() {
-        if (this._doUpdate) {
-            // clodo trick @see nghyd#308
-            setTimeout(() => {
-                this._doUpdate = !this.updateResults();
-            }, 10);
-        }
     }
 
     private mergeLog(result: Result, log: cLog) {
@@ -106,7 +45,7 @@ export class FixedVarResultsComponent extends ResultsComponentDirective implemen
         }
     }
 
-    private get mergedGlobalLogs(): cLog {
+    public get mergedGlobalLogs(): cLog {
         const res = new cLog();
         if (this._fixedResults) {
             this.mergeLog(this._fixedResults.result, res);
@@ -117,42 +56,6 @@ export class FixedVarResultsComponent extends ResultsComponentDirective implemen
         return res;
     }
 
-    /**
-     * met à jour l'affichage des résultats
-     * @returns true si les résultats ont pu être mis à jour
-     */
-    protected updateResults() {
-        const fixedUpdated = this._fixedResults !== undefined && this.fixedResultsComponent !== undefined;
-        if (fixedUpdated) {
-            this.fixedResultsComponent.results = this._fixedResults;
-        }
-
-        let graphUpdated: boolean;
-        let varUpdated: boolean;
-        if (this._varResults && this._varResults.hasResults) {
-            varUpdated = this.varResultsComponent !== undefined;
-            if (varUpdated) {
-                this.varResultsComponent.results = this._varResults;
-            }
-
-            graphUpdated = this.resultsChartComponent !== undefined;
-            if (graphUpdated) {
-                this.resultsChartComponent.results = this._varResults;
-                this.resultsChartComponent.updateView();
-            }
-        } else {
-            varUpdated = true;
-            graphUpdated = true;
-        }
-
-        const logUpdated = this.logComponent !== undefined;
-        if (logUpdated) {
-            this.logComponent.log = this.mergedGlobalLogs;
-        }
-
-        return fixedUpdated && varUpdated && logUpdated && graphUpdated;
-    }
-
     /**
      * affichage de la table des résultats fixés
      */
diff --git a/src/app/components/fixedvar-results/var-results.component.ts b/src/app/components/fixedvar-results/var-results.component.ts
index d1ba56c32..7493401d2 100644
--- a/src/app/components/fixedvar-results/var-results.component.ts
+++ b/src/app/components/fixedvar-results/var-results.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, ElementRef } from "@angular/core";
+import { Component, ViewChild, ElementRef, Input } from "@angular/core";
 
 import { MatDialog } from "@angular/material/dialog";
 
@@ -45,6 +45,7 @@ export class VarResultsComponent extends ResultsComponentDirective {
     }
 
     /** Refreshes results and builds the dataset */
+    @Input()
     public set results(r: VarResults) {
         this._varResults = r;
         this._results = [];
diff --git a/src/app/components/jet-results/jet-results.component.html b/src/app/components/jet-results/jet-results.component.html
index ee434e04f..1acaf47ff 100644
--- a/src/app/components/jet-results/jet-results.component.html
+++ b/src/app/components/jet-results/jet-results.component.html
@@ -2,9 +2,9 @@
     <!-- journal -->
     <log></log>
 
-    <results-chart *ngIf="showVarResults" [hidden]="! showVarResultsChart"></results-chart>
+    <results-chart *ngIf="showVarResults" [hidden]="! showVarResultsChart" [results]=varResults></results-chart>
 
-    <jet-trajectory-chart [hidden]="! hasValidResults"></jet-trajectory-chart>
+    <jet-trajectory-chart [hidden]="! hasValidResults" [results]=trajectoryResults></jet-trajectory-chart>
 
     <div>
         <!-- table des résultats fixés -->
diff --git a/src/app/components/jet-results/jet-results.component.ts b/src/app/components/jet-results/jet-results.component.ts
index 04e068fb0..57258cd1e 100644
--- a/src/app/components/jet-results/jet-results.component.ts
+++ b/src/app/components/jet-results/jet-results.component.ts
@@ -1,7 +1,8 @@
-import { Component, ViewChild } from "@angular/core";
+import { Component } from "@angular/core";
 
 import { FixedVarResultsComponent } from "../fixedvar-results/fixedvar-results.component";
-import { JetTrajectoryChartComponent } from "../jet-trajectory-chart/jet-trajectory-chart.component";
+import { FixedResults } from "../../results/fixed-results";
+import { VarResults } from "../../results/var-results";
 
 @Component({
     selector: "jet-results",
@@ -12,10 +13,6 @@ import { JetTrajectoryChartComponent } from "../jet-trajectory-chart/jet-traject
 })
 export class JetResultsComponent extends FixedVarResultsComponent {
 
-    /** graphique de trajectoire */
-    @ViewChild(JetTrajectoryChartComponent)
-    private jetTrajectoryChartComponent: JetTrajectoryChartComponent;
-
     public get hasResults(): boolean {
         return (
             (this._fixedResults?.hasResults)
@@ -32,33 +29,13 @@ export class JetResultsComponent extends FixedVarResultsComponent {
         );
     }
 
-    public updateView() {
-        if (this.jetTrajectoryChartComponent) {
-            this.jetTrajectoryChartComponent.results = undefined;
+    public get trajectoryResults(): FixedResults | VarResults {
+        // draw chart whether params are variating or not,
+        // hence different Results object for each case
+        if (this._varResults && this._varResults.hasResults) {
+            return this._varResults;
+        } else {
+            return this._fixedResults;
         }
-        super.updateView();
-    }
-
-    /**
-     * met à jour l'affichage des résultats
-     * @returns true si les résultats ont pu être mis à jour
-     */
-    protected updateResults() {
-        const superUpdated = super.updateResults();
-
-        const trajectoryChartUpdated = this.jetTrajectoryChartComponent !== undefined;
-
-        if (trajectoryChartUpdated) {
-            // draw chart whether params are variating or not,
-            // hence different Results object for each case
-            if (this._varResults && this._varResults.hasResults) {
-                this.jetTrajectoryChartComponent.results = this._varResults;
-            } else {
-                this.jetTrajectoryChartComponent.results = this._fixedResults;
-            }
-            this.jetTrajectoryChartComponent.updateView();
-        }
-
-        return superUpdated && trajectoryChartUpdated;
     }
 }
diff --git a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
index 960cda6bd..f4ee238a0 100644
--- a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
+++ b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, ChangeDetectorRef } from "@angular/core";
+import { Component, ViewChild, ChangeDetectorRef, Input } from "@angular/core";
 
 import { ChartComponent } from "angular2-chartjs";
 
@@ -132,7 +132,9 @@ export class JetTrajectoryChartComponent extends ResultsComponentDirective {
         }, 10);
     }
 
+    @Input()
     public set results(r: FixedResults | VarResults) {
+        console.log("miam miam les bons résultats !", r);
         this.forceRebuild(); // used for forcing redefinition of xAxes[0].ticks.min/max in generateScatterChart()
         this._results = r;
 
@@ -171,6 +173,7 @@ export class JetTrajectoryChartComponent extends ResultsComponentDirective {
     }
 
     public updateView() {
+        console.log("----> regenerate trajectory chart !!");
         this.generateScatterChart();
     }
 
diff --git a/src/app/components/log/log.component.html b/src/app/components/log/log.component.html
index 4d3d0424a..5920817ec 100644
--- a/src/app/components/log/log.component.html
+++ b/src/app/components/log/log.component.html
@@ -3,6 +3,6 @@
         <!-- titre -->
         <div class="titre">{{ uitextTitreJournal }}</div>
         <!-- entrées du journal -->
-        <log-entry *ngFor="let m of messages" [_message]="m"></log-entry>
+        <log-entry *ngFor="let m of _log?.messages" [_message]="m"></log-entry>
     </div>
 </div>
diff --git a/src/app/components/log/log.component.ts b/src/app/components/log/log.component.ts
index 18da5657c..5235954b2 100644
--- a/src/app/components/log/log.component.ts
+++ b/src/app/components/log/log.component.ts
@@ -34,13 +34,18 @@ export class LogComponent {
     }
 
     public get hasEntries(): boolean {
-        return this._log?.messages?.length !== 0;
+        return this._log?.messages?.length > 0;
     }
 
-    public get messages(): Message[] {
-        return this._log?.messages;
-    }
+    /* public get messages(): Message[] {
+        let m: Message[] = [];
+        if (this._log !== undefined) {
+            m = this._log.messages;
+        }
+        return m;
+    } */
 
+    @Input()
     public set log(log: cLog) {
         this._log = log;
     }
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts
index abe858dcc..bf70492bf 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results-table.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, ElementRef } from "@angular/core";
+import { Component, ViewChild, ElementRef, Input, OnChanges } from "@angular/core";
 
 import { MacroRugo } from "jalhyd";
 
@@ -15,10 +15,15 @@ import { AppComponent } from "../../app.component";
         "./macrorugo-compound-results-table.component.scss"
     ]
 })
-export class MacrorugoCompoundResultsTableComponent extends ResultsComponentDirective {
+export class MacrorugoCompoundResultsTableComponent extends ResultsComponentDirective implements OnChanges {
 
     /** résultats non mis en forme */
-    private _mrcResults: MacrorugoCompoundResults;
+    @Input()
+    public results: MacrorugoCompoundResults;
+
+    /** index de l'élément de résultat à afficher (modifié par le sélecteur de conditions limites) */
+    @Input()
+    public variableIndex = 0;
 
     /** entêtes des colonnes */
     private _headers: string[];
@@ -36,21 +41,19 @@ export class MacrorugoCompoundResultsTableComponent extends ResultsComponentDire
         super();
     }
 
-    public set results(r: MacrorugoCompoundResults) {
-        this._mrcResults = r;
-
+    public ngOnChanges() {
+        // rebuild dataset every time results or variableIndex change
         this._dataSet = [];
         if (
-            this._mrcResults
-            && this._mrcResults.childrenResults
-            && this._mrcResults.childrenResults.length > 0
-            && ! this._mrcResults.hasOnlyErrors()
+            this.results
+            && this.results.childrenResults
+            && this.results.childrenResults.length > 0
+            && ! this.results.hasOnlyErrors()
         ) {
-            const pr = this._mrcResults;
+            const pr = this.results;
             const nDigits = this.appSetupService.displayPrecision;
             // when a parameter is variating, index of the variating parameter
             // values to build the data from
-            const vi = pr.variableIndex;
 
             // refresh headers here if language changed
             this._headers = pr.headers;
@@ -58,13 +61,13 @@ export class MacrorugoCompoundResultsTableComponent extends ResultsComponentDire
             // lines 1 - n-1 (aprons)
             for (let i = 0; i < pr.childrenResults.length; i++) {
                 // protect loop contents with if(vCalc) ? Will hide erroneous apron results..
-                const res = pr.childrenResults[i].resultElements[vi].values;
+                const res = pr.childrenResults[i].resultElements[this.variableIndex].values;
                 const nub = (pr.childrenResults[i].sourceNub as MacroRugo);
                 // does ZF1 or B vary ?
                 let zf1: number;
                 try {
                     if (nub.prms.ZF1.hasMultipleValues) {
-                        zf1 = nub.prms.ZF1.getInferredValuesList()[vi];
+                        zf1 = nub.prms.ZF1.getInferredValuesList()[this.variableIndex];
                     } else {
                         zf1 = nub.prms.ZF1.singleValue;
                     }
@@ -74,7 +77,7 @@ export class MacrorugoCompoundResultsTableComponent extends ResultsComponentDire
                 let b: number;
                 try {
                     if (nub.prms.B.hasMultipleValues) {
-                        b = nub.prms.B.getInferredValuesList()[vi];
+                        b = nub.prms.B.getInferredValuesList()[this.variableIndex];
                     } else {
                         b = nub.prms.B.singleValue;
                     }
@@ -84,7 +87,7 @@ export class MacrorugoCompoundResultsTableComponent extends ResultsComponentDire
                 let Y: number;
                 try {
                     if (nub.prms.Y.hasMultipleValues) {
-                        Y = nub.prms.Y.getInferredValuesList()[vi];
+                        Y = nub.prms.Y.getInferredValuesList()[this.variableIndex];
                     } else {
                         Y = nub.prms.Y.singleValue;
                     }
@@ -111,7 +114,7 @@ export class MacrorugoCompoundResultsTableComponent extends ResultsComponentDire
             this._dataSet.push([
                 this.intlService.localizeText("INFO_LIB_TOTAL"),
                 "", "", "",
-                pr.result.resultElements[vi].vCalc.toFixed(nDigits),
+                pr.result.resultElements[this.variableIndex].vCalc.toFixed(nDigits),
                 "", "", "", "", "", ""
             ]);
         }
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
index 85b150db8..ed2f042bc 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
@@ -1,15 +1,16 @@
 <div class="container">
 
-    <log #generalLog [logTitle]="uitextGeneralLogTitle">log général</log>
+    <log #generalLog [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
 
-    <variable-results-selector [results]="mrcResults" (indexChange)="variableIndexChanged()">
+    <variable-results-selector [results]=mrcResults [variatedParameters]=mrcResults?.variatedParameters>
     </variable-results-selector>
 
-    <log #iterationLog></log>
+    <log #iterationLog [log]=iterationLog></log>
 
     <div>
         <!-- tableau de résultats -->
-        <macrorugo-compound-results-table *ngIf="hasDisplayableResults" [results]="mrcResults">
+        <macrorugo-compound-results-table *ngIf="hasDisplayableResults"
+          [results]=mrcResults [variableIndex]=mrcResults?.variableIndex>
         </macrorugo-compound-results-table>
     </div>
 
@@ -24,7 +25,7 @@
         fxLayoutAlign="space-around start">
         <!-- <pab-profile-chart *ngIf="hasDisplayableResults" fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </pab-profile-chart> -->
-        <results-chart *ngIf="hasDisplayableResults" fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
+        <results-chart *ngIf="hasDisplayableResults" [results]=plottableResults fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </results-chart>
     </div>
 
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
index d2d932838..cbe53d860 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
@@ -1,18 +1,14 @@
-import { Component, ViewChild, DoCheck } from "@angular/core";
+import { Component, Input, OnChanges } from "@angular/core";
 
 import { Result, cLog, Message, MessageCode, MessageSeverity, MRCInclination } from "jalhyd";
 
 import { fv } from "../../../app/util";
 
-import { LogComponent } from "../../components/log/log.component";
 import { CalculatorResults } from "../../results/calculator-results";
 import { NgParameter } from "../../formulaire/elements/ngparam";
 import { ApplicationSetupService } from "../../services/app-setup.service";
 import { PlottableData } from "../../results/plottable-data";
-import { ResultsChartComponent } from "../results-chart/results-chart.component";
 import { I18nService } from "../../services/internationalisation.service";
-import { VariableResultsSelectorComponent } from "../variable-results-selector/variable-results-selector.component";
-import { MacrorugoCompoundResultsTableComponent } from "./macrorugo-compound-results-table.component";
 import { MacrorugoCompoundResults } from "../../results/macrorugo-compound-results";
 import { PlottableMacrorugoCompoundResults } from "../../results/plottable-macrorugo-compound-results";
 import { ResultsComponentDirective } from "../fixedvar-results/results.component";
@@ -24,7 +20,7 @@ import { ResultsComponentDirective } from "../fixedvar-results/results.component
         "./macrorugo-compound-results.component.scss"
     ]
 })
-export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective implements DoCheck {
+export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective implements OnChanges {
 
     /** résultats non mis en forme */
     private _mrcResults: MacrorugoCompoundResults;
@@ -32,24 +28,6 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
     /** résultats mis en forme pour le graphique de données (classique) */
     private _plottableResults: PlottableMacrorugoCompoundResults;
 
-    /** true si les résultats doiventt être remis à jour */
-    private _doUpdate = false;
-
-    @ViewChild(MacrorugoCompoundResultsTableComponent)
-    private mrcResultsTableComponent: MacrorugoCompoundResultsTableComponent;
-
-    @ViewChild(VariableResultsSelectorComponent)
-    private variableResultsSelectorComponent: VariableResultsSelectorComponent;
-
-    @ViewChild("generalLog")
-    private generalLogComponent: LogComponent;
-
-    @ViewChild("iterationLog")
-    private iterationLogComponent: LogComponent;
-
-    @ViewChild(ResultsChartComponent)
-    private resultsChartComponent: ResultsChartComponent;
-
     constructor(
         private appSetupService: ApplicationSetupService,
         private i18nService: I18nService,
@@ -58,50 +36,16 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
         this._plottableResults = new PlottableMacrorugoCompoundResults();
     }
 
+    public ngOnChanges() {
+        console.log("--------> MRCR_C changes…");
+    }
+
+    @Input()
     public set results(rs: CalculatorResults[]) {
         this._mrcResults = undefined;
         if (rs.length > 0 && rs[0] instanceof MacrorugoCompoundResults) {
             this._mrcResults = rs[0] as MacrorugoCompoundResults;
         }
-        this.updateView();
-    }
-
-    /**
-     * update results table and chart when the variable index changed (event sent by
-     * VariableResultsSelectorComponent); variable index is already set in
-     * mrcResults at this time
-     */
-    public variableIndexChanged() {
-        this.updateView();
-    }
-
-    public updateView() {
-        if (this.iterationLogComponent) {
-            this.iterationLogComponent.log = undefined;
-        }
-        if (this.generalLogComponent) {
-            this.generalLogComponent.log = undefined;
-        }
-        if (this.mrcResultsTableComponent) {
-            this.mrcResultsTableComponent.results = undefined;
-        }
-        if (this.variableResultsSelectorComponent) {
-            this.variableResultsSelectorComponent.results = undefined;
-        }
-        if (this.resultsChartComponent) {
-            this.resultsChartComponent.results = undefined;
-        }
-        // set _doUpdate flag so that results are rebuilt on the next Angular display cycle
-        this._doUpdate = false;
-        if (this._mrcResults !== undefined) {
-            this._doUpdate = this._doUpdate || this._mrcResults.hasResults || this._mrcResults.hasLog;
-        }
-    }
-
-    public ngDoCheck() {
-        if (this._doUpdate) {
-            this._doUpdate = !this.updateResults();
-        }
     }
 
     private mergeGlobalLog(result: Result, log: cLog) {
@@ -177,7 +121,7 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
      * du sélecteur d'itération : messages globaux et / ou résumé des messages
      * spécifiques à chaque ResultElement
      */
-    private get globalLog(): cLog {
+    public get globalLog(): cLog {
         const l = new cLog();
         if (this._mrcResults && this.mrcResults.variatedParameters.length > 0) {
             this.mergeGlobalLog(this._mrcResults.result, l);
@@ -203,7 +147,7 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
      * du sélecteur d'itération : messages globaux et / ou résumé des messages
      * spécifiques à chaque ResultElement
      */
-    private get iterationLog(): cLog {
+    public get iterationLog(): cLog {
         const l = new cLog();
         if (this._mrcResults) {
             if (this.mrcResults.variatedParameters.length > 0) {
@@ -238,46 +182,6 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
         return l;
     }
 
-    /**
-     * met à jour l'affichage des résultats
-     * @returns true si les résultats ont pu être mis à jour
-     */
-    private updateResults() {
-        let mrcUpdated: boolean;
-        let resultsChartUpdated: boolean;
-        let selectorUpdated: boolean;
-
-        // results or not, there might be a log
-        const logUpdated = (this.iterationLogComponent !== undefined || this.generalLogComponent !== undefined); // gne ?
-        if (logUpdated) {
-            // order of logs is important !
-            this.iterationLogComponent.log = this.iterationLog;
-            this.generalLogComponent.log = this.globalLog;
-        }
-
-        if (this.hasResults) {
-            mrcUpdated = this.mrcResultsTableComponent !== undefined;
-            if (mrcUpdated) {
-                this.mrcResultsTableComponent.results = this._mrcResults;
-            }
-            selectorUpdated = this.variableResultsSelectorComponent !== undefined;
-            if (selectorUpdated) {
-                this.variableResultsSelectorComponent.results = this._mrcResults;
-            }
-            resultsChartUpdated = this.resultsChartComponent !== undefined;
-            if (resultsChartUpdated) {
-                this.resultsChartComponent.results = this.plottableResults;
-                this.resultsChartComponent.updateView();
-            }
-        } else {
-            mrcUpdated = true;
-            resultsChartUpdated = true;
-            selectorUpdated = true;
-        }
-
-        return mrcUpdated && logUpdated && resultsChartUpdated && selectorUpdated;
-    }
-
     public get mrcResults() {
         return this._mrcResults;
     }
diff --git a/src/app/components/pab-profile-chart/pab-profile-chart.component.ts b/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
index ce34f4dae..6f24b8ab1 100644
--- a/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
+++ b/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, ChangeDetectorRef } from "@angular/core";
+import { Component, ViewChild, ChangeDetectorRef, Input } from "@angular/core";
 
 import { ChartComponent } from "angular2-chartjs";
 
@@ -125,6 +125,7 @@ export class PabProfileChartComponent extends ResultsComponentDirective {
         };
     }
 
+    @Input()
     public set results(r: PabResults) {
         this._results = r;
 
diff --git a/src/app/components/pab-results/pab-results-table.component.ts b/src/app/components/pab-results/pab-results-table.component.ts
index 45418cf16..3591658a7 100644
--- a/src/app/components/pab-results/pab-results-table.component.ts
+++ b/src/app/components/pab-results/pab-results-table.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, ElementRef } from "@angular/core";
+import { Component, ViewChild, ElementRef, Input, OnChanges } from "@angular/core";
 
 import { CloisonAval, Result, capitalize } from "jalhyd";
 
@@ -15,10 +15,15 @@ import { fv } from "../../util";
         "./pab-results-table.component.scss"
     ]
 })
-export class PabResultsTableComponent extends ResultsComponentDirective {
+export class PabResultsTableComponent extends ResultsComponentDirective implements OnChanges {
 
     /** résultats non mis en forme */
-    private _pabResults: PabResults;
+    @Input()
+    public results: PabResults;
+
+    /** index de l'élément de résultat à afficher (modifié par le sélecteur de conditions limites) */
+    @Input()
+    public variableIndex = 0;
 
     /** entêtes des colonnes */
     private _headers: string[];
@@ -35,33 +40,15 @@ export class PabResultsTableComponent extends ResultsComponentDirective {
         super();
     }
 
-    private getJetTypes(re: Result, vi: number): string {
-        // jet type for each device
-        const devices = re.sourceNub.getChildren();
-        const jetTypes: string[] = devices.map((device) => {
-            const jt = device.result.resultElements[vi].getValue("ENUM_StructureJetType");
-            let jetType = capitalize(this.intlService.localizeText("INFO_ENUM_STRUCTUREJETTYPE_" + jt));
-            if (devices.length > 1) {
-                // evil HTML injection in table cell (simpler)
-                jetType = this.intlService.localizeText("INFO_LIB_FS_OUVRAGE") + " n°"
-                    + (device.findPositionInParent() + 1) + ": " + jetType;
-            }
-            return jetType;
-        });
-        return `<div class="inner-cell-line">` + jetTypes.join(`, </div><div class="inner-cell-line">`) + `</div>`;
-    }
-
-    public set results(r: PabResults) {
-        this._pabResults = r;
-
+    public ngOnChanges() {
         this._dataSet = [];
         if (
-            this._pabResults
-            && this._pabResults.cloisonsResults
-            && this._pabResults.cloisonsResults.length > 0
-            && ! this._pabResults.hasOnlyErrors()
+            this.results
+            && this.results.cloisonsResults
+            && this.results.cloisonsResults.length > 0
+            && ! this.results.hasOnlyErrors()
         ) {
-            const pr = this._pabResults;
+            const pr = this.results;
             // when a parameter is variating, index of the variating parameter
             // values to build the data from
             const vi = pr.variableIndex;
@@ -134,6 +121,22 @@ export class PabResultsTableComponent extends ResultsComponentDirective {
         }
     }
 
+    private getJetTypes(re: Result, vi: number): string {
+        // jet type for each device
+        const devices = re.sourceNub.getChildren();
+        const jetTypes: string[] = devices.map((device) => {
+            const jt = device.result.resultElements[vi].getValue("ENUM_StructureJetType");
+            let jetType = this.intlService.localizeText("INFO_ENUM_STRUCTUREJETTYPE_" + jt);
+            if (devices.length > 1) {
+                // evil HTML injection in table cell (simpler)
+                jetType = this.intlService.localizeText("INFO_LIB_FS_OUVRAGE") + " n°"
+                    + (device.findPositionInParent() + 1) + ": " + jetType;
+            }
+            return jetType;
+        });
+        return `<div class="inner-cell-line">` + jetTypes.join(`, </div><div class="inner-cell-line">`) + `</div>`;
+    }
+
     public get headers() {
         return this._headers;
     }
diff --git a/src/app/components/pab-results/pab-results.component.html b/src/app/components/pab-results/pab-results.component.html
index 9bb311053..8dc980039 100644
--- a/src/app/components/pab-results/pab-results.component.html
+++ b/src/app/components/pab-results/pab-results.component.html
@@ -1,24 +1,26 @@
 <div class="container">
 
-    <log #generalLog [logTitle]="uitextGeneralLogTitle">log général</log>
+    <log #generalLog [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
 
-    <variable-results-selector [results]="pabResults" (indexChange)="variableIndexChanged()">
+    <variable-results-selector [results]="pabResults" [variatedParameters]=pabResults?.variatedParameters>
     </variable-results-selector>
 
-    <log #iterationLog></log>
+    <log #iterationLog [log]=iterationLog></log>
 
     <div>
         <!-- tableau de résultats -->
-        <pab-results-table *ngIf="hasDisplayableResults" [results]="pabResults"></pab-results-table>
+        <pab-results-table *ngIf="hasDisplayableResults"
+          [results]=pabResults [variableIndex]=pabResults?.variableIndex>
+        </pab-results-table>
     </div>
 
     <quicknav *ngIf="hasDisplayableResults" [items]="[ 'input', 'results', 'charts' ]" [currentItem]="'charts'"
         [align]="'left'"></quicknav>
 
     <div id="pab-graphs-container" class="container" fxLayout="row wrap" fxLayoutAlign="space-around start">
-        <pab-profile-chart *ngIf="hasDisplayableResults" fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
+        <pab-profile-chart *ngIf="hasDisplayableResults" [results]=pabResults fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </pab-profile-chart>
-        <results-chart *ngIf="hasDisplayableResults" fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
+        <results-chart *ngIf="hasDisplayableResults" [results]=plottableResults fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </results-chart>
     </div>
 
diff --git a/src/app/components/pab-results/pab-results.component.ts b/src/app/components/pab-results/pab-results.component.ts
index 309a6647a..011ba0bd1 100644
--- a/src/app/components/pab-results/pab-results.component.ts
+++ b/src/app/components/pab-results/pab-results.component.ts
@@ -1,17 +1,12 @@
-import { Component, ViewChild, DoCheck } from "@angular/core";
+import { Component, Input } from "@angular/core";
 
 import { Result, cLog, Message, MessageCode, MessageSeverity } from "jalhyd";
 
-import { LogComponent } from "../../components/log/log.component";
 import { CalculatorResults } from "../../results/calculator-results";
-import { PabResultsTableComponent } from "./pab-results-table.component";
 import { PabResults } from "../../results/pab-results";
-import { VariableResultsSelectorComponent } from "../variable-results-selector/variable-results-selector.component";
 import { PlottableData } from "../../results/plottable-data";
 import { PlottablePabResults } from "../../results/plottable-pab-results";
-import { ResultsChartComponent } from "../results-chart/results-chart.component";
 import { I18nService } from "../../services/internationalisation.service";
-import { PabProfileChartComponent } from "../pab-profile-chart/pab-profile-chart.component";
 import { ResultsComponentDirective } from "../fixedvar-results/results.component";
 
 @Component({
@@ -21,7 +16,7 @@ import { ResultsComponentDirective } from "../fixedvar-results/results.component
         "./pab-results.component.scss"
     ]
 })
-export class PabResultsComponent extends ResultsComponentDirective implements DoCheck {
+export class PabResultsComponent extends ResultsComponentDirective {
 
     /** résultats non mis en forme */
     private _pabResults: PabResults;
@@ -29,27 +24,6 @@ export class PabResultsComponent extends ResultsComponentDirective implements Do
     /** résultats mis en forme pour le graphique de données (classique) */
     private _plottableResults: PlottablePabResults;
 
-    /** true si les résultats doiventt être remis à jour */
-    private _doUpdate = false;
-
-    @ViewChild(PabResultsTableComponent)
-    private pabResultsTableComponent: PabResultsTableComponent;
-
-    @ViewChild(VariableResultsSelectorComponent)
-    private variableResultsSelectorComponent: VariableResultsSelectorComponent;
-
-    @ViewChild("generalLog")
-    private generalLogComponent: LogComponent;
-
-    @ViewChild("iterationLog")
-    private iterationLogComponent: LogComponent;
-
-    @ViewChild(ResultsChartComponent)
-    private resultsChartComponent: ResultsChartComponent;
-
-    @ViewChild(PabProfileChartComponent)
-    private profileChartComponent: PabProfileChartComponent;
-
     constructor(
         private i18nService: I18nService,
     ) {
@@ -57,53 +31,13 @@ export class PabResultsComponent extends ResultsComponentDirective implements Do
         this._plottableResults = new PlottablePabResults();
     }
 
+    @Input()
     public set results(rs: CalculatorResults[]) {
         this._pabResults = undefined;
         if (rs.length > 0 && rs[0] instanceof PabResults) {
             this._pabResults = rs[0] as PabResults;
         }
-        this.updateView();
-    }
-
-    /**
-     * update results table and chart when the variable index changed (event sent by
-     * VariableResultsSelectorComponent); variable index is already set in
-     * pabResults at this time
-     */
-    public variableIndexChanged() {
-        this.updateView();
-    }
-
-    public updateView() {
-        if (this.iterationLogComponent) {
-            this.iterationLogComponent.log = undefined;
-        }
-        if (this.generalLogComponent) {
-            this.generalLogComponent.log = undefined;
-        }
-        if (this.pabResultsTableComponent) {
-            this.pabResultsTableComponent.results = undefined;
-        }
-        if (this.variableResultsSelectorComponent) {
-            this.variableResultsSelectorComponent.results = undefined;
-        }
-        if (this.resultsChartComponent) {
-            this.resultsChartComponent.results = undefined;
-        }
-        if (this.profileChartComponent) {
-            this.profileChartComponent.results = undefined;
-        }
-        // set _doUpdate flag so that results are rebuilt on the next Angular display cycle
-        this._doUpdate = false;
-        if (this._pabResults !== undefined) {
-            this._doUpdate = this._doUpdate || this._pabResults.hasResults || this._pabResults.hasLog;
-        }
-    }
-
-    public ngDoCheck() {
-        if (this._doUpdate) {
-            this._doUpdate = !this.updateResults();
-        }
+        // this.updateView();
     }
 
     private mergeGlobalLog(result: Result, log: cLog) {
@@ -199,7 +133,7 @@ export class PabResultsComponent extends ResultsComponentDirective implements Do
      * du sélecteur d'itération : messages globaux et / ou résumé des messages
      * spécifiques à chaque ResultElement
      */
-    private get globalLog(): cLog {
+    public get globalLog(): cLog {
         const l = new cLog();
         if (this._pabResults && this.pabResults.variatedParameters.length > 0) {
             this.mergeGlobalLog(this._pabResults.result, l);
@@ -266,53 +200,6 @@ export class PabResultsComponent extends ResultsComponentDirective implements Do
         return l;
     }
 
-    /**
-     * met à jour l'affichage des résultats
-     * @returns true si les résultats ont pu être mis à jour
-     */
-    private updateResults() {
-        let pabUpdated: boolean;
-        let resultsChartUpdated: boolean;
-        let profileChartUpdated: boolean;
-        let selectorUpdated: boolean;
-
-        // results or not, there might be a log
-        const logUpdated = (this.iterationLogComponent !== undefined || this.generalLogComponent !== undefined); // gne ?
-        if (logUpdated) {
-            // order of logs is important !
-            this.iterationLogComponent.log = this.iterationLog;
-            this.generalLogComponent.log = this.globalLog;
-        }
-
-        if (this.hasResults) {
-            pabUpdated = this.pabResultsTableComponent !== undefined;
-            if (pabUpdated) {
-                this.pabResultsTableComponent.results = this._pabResults;
-            }
-            selectorUpdated = this.variableResultsSelectorComponent !== undefined;
-            if (selectorUpdated) {
-                this.variableResultsSelectorComponent.results = this._pabResults;
-            }
-            resultsChartUpdated = this.resultsChartComponent !== undefined;
-            if (resultsChartUpdated) {
-                this.resultsChartComponent.results = this.plottableResults;
-                this.resultsChartComponent.updateView();
-            }
-            profileChartUpdated = this.profileChartComponent !== undefined;
-            if (profileChartUpdated) {
-                this.profileChartComponent.results = this._pabResults;
-                this.profileChartComponent.updateView();
-            }
-        } else {
-            pabUpdated = true;
-            resultsChartUpdated = true;
-            profileChartUpdated = true;
-            selectorUpdated = true;
-        }
-
-        return pabUpdated && logUpdated && resultsChartUpdated && profileChartUpdated && selectorUpdated;
-    }
-
     public get pabResults() {
         return this._pabResults;
     }
diff --git a/src/app/components/pb-results/pb-cloison-results.component.ts b/src/app/components/pb-results/pb-cloison-results.component.ts
index 0d2fe30cc..0a59b6a8b 100644
--- a/src/app/components/pb-results/pb-cloison-results.component.ts
+++ b/src/app/components/pb-results/pb-cloison-results.component.ts
@@ -1,4 +1,4 @@
-import { Component } from "@angular/core";
+import { Component, Input } from "@angular/core";
 
 import { FixedResultsComponent } from "../fixedvar-results/fixed-results.component";
 import { NgParameter } from "../../formulaire/elements/ngparam";
@@ -16,6 +16,7 @@ import { Result, ResultElement } from "jalhyd";
 })
 export class PbCloisonResultsComponent extends FixedResultsComponent {
 
+    @Input()
     public set results(r: PbCloisonResults) {
         this._fixedResults = r;
     }
diff --git a/src/app/components/pb-results/pb-results-table.component.ts b/src/app/components/pb-results/pb-results-table.component.ts
index 925eab960..c5d8dff4d 100644
--- a/src/app/components/pb-results/pb-results-table.component.ts
+++ b/src/app/components/pb-results/pb-results-table.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, ElementRef } from "@angular/core";
+import { Component, ViewChild, ElementRef, Input } from "@angular/core";
 
 import { PreBarrage, PbBassin } from "jalhyd";
 
@@ -35,6 +35,7 @@ export class PbResultsTableComponent extends ResultsComponentDirective {
         super();
     }
 
+    @Input()
     public set results(r: PrebarrageResults) {
         this._pbResults = r;
 
diff --git a/src/app/components/pb-results/pb-results.component.html b/src/app/components/pb-results/pb-results.component.html
index 80a7d4501..cce785e43 100644
--- a/src/app/components/pb-results/pb-results.component.html
+++ b/src/app/components/pb-results/pb-results.component.html
@@ -1,16 +1,16 @@
 <div class="container">
-    <log #generalLog [logTitle]="uitextGeneralLogTitle">log général</log>
+    <log #generalLog [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
 
-    <variable-results-selector [results]="pbResults" (indexChange)="variableIndexChanged()">
+    <variable-results-selector [results]=pbResults>
     </variable-results-selector>
 
-    <log #iterationLog></log>
+    <log #iterationLog [log]=iterationLog></log>
 
     <!-- tableau de résultats des bassins -->
-    <pb-results-table *ngIf="hasBasinResults" [results]="pbResults"></pb-results-table>
+    <pb-results-table *ngIf="hasBasinResults" [results]=pbResults></pb-results-table>
 
     <!-- table des résultats fixés -->
-    <pb-cloison-results *ngIf="hasWallResults" [results]="pbResults.cloisonResults"></pb-cloison-results>
+    <pb-cloison-results *ngIf="hasWallResults" [results]=pbResults.cloisonResults></pb-cloison-results>
 
     <!-- <quicknav *ngIf="hasDisplayableResults" [items]="[ 'input', 'results', 'charts' ]"
         [currentItem]="'charts'" [align]="'left'"></quicknav> -->
diff --git a/src/app/components/pb-results/pb-results.component.ts b/src/app/components/pb-results/pb-results.component.ts
index 0362c6b8b..666257c7d 100644
--- a/src/app/components/pb-results/pb-results.component.ts
+++ b/src/app/components/pb-results/pb-results.component.ts
@@ -1,15 +1,10 @@
-import { Component, ViewChild, DoCheck } from "@angular/core";
+import { Component, Input } from "@angular/core";
 
-import { LogComponent } from "../log/log.component";
 import { CalculatorResults } from "../../results/calculator-results";
-import { PbResultsTableComponent } from "./pb-results-table.component";
 import { PrebarrageResults } from "../../results/prebarrage-results";
-import { VariableResultsSelectorComponent } from "../variable-results-selector/variable-results-selector.component";
 import { I18nService } from "../../services/internationalisation.service";
-import { PbCloisonResultsComponent } from "./pb-cloison-results.component";
-import { FixedResults } from "../../results/fixed-results";
 
-import { Result } from "jalhyd";
+import { cLog } from "jalhyd";
 
 @Component({
     selector: "pb-results",
@@ -18,36 +13,16 @@ import { Result } from "jalhyd";
         "./pb-results.component.scss"
     ]
 })
-export class PbResultsComponent implements DoCheck {
+export class PbResultsComponent {
 
     /** résultats des bassins, non mis en forme */
     private _pbResults: PrebarrageResults;
 
-    /** true si les résultats doiventt être remis à jour */
-    private _doUpdate = false;
-
-    @ViewChild(PbResultsTableComponent)
-    private pbResultsTableComponent: PbResultsTableComponent;
-
-    @ViewChild(VariableResultsSelectorComponent)
-    private variableResultsSelectorComponent: VariableResultsSelectorComponent;
-
-    @ViewChild(PbCloisonResultsComponent)
-    private pbCloisonResultsComponent: PbCloisonResultsComponent;
-
-    @ViewChild("generalLog")
-    private generalLogComponent: LogComponent;
-
-    @ViewChild("iterationLog")
-    private iterationLogComponent: LogComponent;
-
-    /* @ViewChild(PabProfileChartComponent)
-    private profileChartComponent: PabProfileChartComponent; */
-
     constructor(
         private i18nService: I18nService,
     ) { }
 
+    @Input()
     public set results(rs: CalculatorResults[]) {
         this._pbResults = undefined;
         for (const r of rs) {
@@ -55,7 +30,7 @@ export class PbResultsComponent implements DoCheck {
                 this._pbResults = r as PrebarrageResults;
             }
         }
-        this.updateView();
+        // this.updateView();
     }
 
     public get pbResults() {
@@ -77,47 +52,6 @@ export class PbResultsComponent implements DoCheck {
         return this._pbResults && this._pbResults.hasWallResults;
     }
 
-    /**
-     * update results table and chart when the variable index changed (event sent by
-     * VariableResultsSelectorComponent); variable index is already set in
-     * pbResults at this time
-     */
-    public variableIndexChanged() {
-        this.updateView();
-    }
-
-    public updateView() {
-        if (this.iterationLogComponent) {
-            this.iterationLogComponent.log = undefined;
-        }
-        if (this.generalLogComponent) {
-            this.generalLogComponent.log = undefined;
-        }
-        if (this.pbResultsTableComponent) {
-            this.pbResultsTableComponent.results = undefined;
-        }
-        if (this.variableResultsSelectorComponent) {
-            this.variableResultsSelectorComponent.results = undefined;
-        }
-        if (this.pbCloisonResultsComponent) {
-            this.pbCloisonResultsComponent.results = undefined;
-        }
-        /* if (this.profileChartComponent) {
-            this.profileChartComponent.results = undefined;
-        } */
-        // set _doUpdate flag so that results are rebuilt on the next Angular display cycle
-        this._doUpdate = false;
-        if (this._pbResults !== undefined) {
-            this._doUpdate = this._doUpdate || this._pbResults.hasResults || this._pbResults.hasLog;
-        }
-    }
-
-    public ngDoCheck() {
-        if (this._doUpdate) {
-            this._doUpdate = !this.updateResults();
-        }
-    }
-
     /* private mergeGlobalLog(result: Result, log: cLog) {
         if (result) {
             if (result.hasGlobalLog()) {
@@ -211,9 +145,9 @@ export class PbResultsComponent implements DoCheck {
      * du sélecteur d'itération : messages globaux et / ou résumé des messages
      * spécifiques à chaque ResultElement
      */
-    /* private get globalLog(): cLog {
+    public get globalLog(): cLog {
         const l = new cLog();
-        if (this._pbResults && this.pbResults.variatedParameters.length > 0) {
+        /* if (this._pbResults && this.pbResults.variatedParameters.length > 0) {
             this.mergeGlobalLog(this._pbResults.result, l);
             // un problème avec la PAB en général / les cloisons, à une étape quelconque ?
             if (
@@ -228,107 +162,8 @@ export class PbResultsComponent implements DoCheck {
                 l.add(m);
                 // l.add(new Message(MessageCode.WARNING_PROBLEMS_ENCOUNTERED));
             }
-        } // sinon pas de log global (aucun paramètre ne varie)
-        return l;
-    } */
-
-    /**
-     * Retourne les logs à afficher dans le composant de log global, au dessus
-     * du sélecteur d'itération : messages globaux et / ou résumé des messages
-     * spécifiques à chaque ResultElement
-     */
-    /* private get iterationLog(): cLog {
-        const l = new cLog();
-        if (this._pbResults) {
-            if (this.pbResults.variatedParameters.length > 0) {
-                // A. si un paramètre varie
-                const vi = this._pbResults.variableIndex;
-                // log de la PAB pour l'itération en cours
-                if (
-                    this._pbResults.result
-                    && this._pbResults.result.hasResultElements()
-                    && this._pbResults.result.resultElements[vi]
-                    && this._pbResults.result.resultElements[vi].hasLog()
-                ) {
-                    l.addLog(this._pbResults.result.resultElements[vi].log);
-                }
-                // logs des enfants pour l'itération en cours
-                for (const cr of this._pbResults.cloisonsResults) {
-                    if (cr && cr.hasResultElements() && cr.resultElements[vi].hasLog()) {
-                        l.addLog(cr.resultElements[vi].log);
-                    }
-                }
-                if (this._pbResults.cloisonAvalResults && this._pbResults.cloisonAvalResults.resultElements[vi].hasLog()) {
-                    l.addLog(this._pbResults.cloisonAvalResults.resultElements[vi].log);
-                }
-            } else {
-                // B. si aucun paramètre ne varie
-                this.mergeGlobalLog(this._pbResults.result, l); // faut bien mettre le log global quelque part
-                // logs des enfants
-                for (const cr of this._pbResults.cloisonsResults) {
-                    if (cr && cr.hasResultElements() && cr.resultElement.hasLog()) {
-                        l.addLog(cr.resultElement.log);
-                    }
-                }
-                if (this._pbResults.cloisonAvalResults && this._pbResults.cloisonAvalResults.resultElement.hasLog()) {
-                    l.addLog(this._pbResults.cloisonAvalResults.resultElement.log);
-                }
-            }
-        }
+        } // sinon pas de log global (aucun paramètre ne varie) */
         return l;
-    } */
-
-    /**
-     * met à jour l'affichage des résultats
-     * @returns true si les résultats ont pu être mis à jour
-     */
-    private updateResults() {
-        let pbTableUpdated: boolean;
-        let profileChartUpdated: boolean;
-        let selectorUpdated: boolean;
-        let cloisonResultsUpdated: boolean;
-
-        // results or not, there might be a log
-        const logUpdated = (this.iterationLogComponent !== undefined || this.generalLogComponent !== undefined); // gne ?
-        if (logUpdated) {
-            // order of logs is important !
-            /* this.iterationLogComponent.log = this.iterationLog;
-            this.generalLogComponent.log = this.globalLog; */
-        }
-
-        // show selector as long as any result is present
-        if (this.hasResults) {
-            selectorUpdated = this.variableResultsSelectorComponent !== undefined;
-            if (selectorUpdated) {
-                this.variableResultsSelectorComponent.results = this._pbResults;
-            }
-        } else {
-            selectorUpdated = true;
-        }
-        if (this.hasBasinResults) {
-            pbTableUpdated = this.pbResultsTableComponent !== undefined;
-            if (pbTableUpdated) {
-                this.pbResultsTableComponent.results = this._pbResults;
-            }
-            /* profileChartUpdated = this.profileChartComponent !== undefined;
-            if (profileChartUpdated) {
-                this.profileChartComponent.results = this._pbResults;
-                this.profileChartComponent.updateView();
-            } */
-        } else {
-            pbTableUpdated = true;
-            profileChartUpdated = true;
-        }
-        if (this.hasWallResults) {
-            cloisonResultsUpdated = this.pbCloisonResultsComponent !== undefined;
-            if (cloisonResultsUpdated) {
-                this.pbCloisonResultsComponent.results = this._pbResults.cloisonResults;
-            }
-        } else {
-            cloisonResultsUpdated = true;
-        }
-
-        return pbTableUpdated && logUpdated && profileChartUpdated && selectorUpdated && cloisonResultsUpdated;
     }
 
     public get uitextGeneralLogTitle(): string {
diff --git a/src/app/components/remous-results/remous-results.component.html b/src/app/components/remous-results/remous-results.component.html
index ed96cbf12..da5ce69b5 100644
--- a/src/app/components/remous-results/remous-results.component.html
+++ b/src/app/components/remous-results/remous-results.component.html
@@ -42,10 +42,10 @@
 
 
 <!-- journal -->
-<log></log>
+<log [log]=log></log>
 
 <div [hidden]="! hasData">
     <!-- *ngIf breaks @ViewChild availability-->
     <!-- résultats numériques -->
-    <var-results></var-results>
-</div>
\ No newline at end of file
+    <var-results [results]=varResults></var-results>
+</div>
diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts
index ecf98435a..4a18b7fb9 100644
--- a/src/app/components/remous-results/remous-results.component.ts
+++ b/src/app/components/remous-results/remous-results.component.ts
@@ -1,17 +1,16 @@
-import { Component, ViewChild, DoCheck } from "@angular/core";
+import { Component, Input } from "@angular/core";
 
-import { INumberIterator, CourbeRemousParams, CourbeRemous, ParamDefinition, ParamDomain, ParamDomainValue } from "jalhyd";
+import { INumberIterator, CourbeRemousParams, CourbeRemous, ParamDefinition, ParamDomainValue, cLog } from "jalhyd";
 
 import { I18nService } from "../../services/internationalisation.service";
-import { LogComponent } from "../../components/log/log.component";
 import { RemousResults } from "../../results/remous-results";
 import { CalculatorResults } from "../../results/calculator-results";
-import { VarResultsComponent } from "../fixedvar-results/var-results.component";
 import { FormulaireService } from "../../services/formulaire.service";
 import { ResultsComponentDirective } from "../fixedvar-results/results.component";
 import { AppComponent } from "../../app.component";
 import { LineData, ChartData } from "./line-and-chart-data";
 import { fv } from "../../util";
+import { VarResults } from "../../results/var-results";
 
 @Component({
     selector: "remous-results",
@@ -20,7 +19,7 @@ import { fv } from "../../util";
         "./remous-results.component.scss"
     ]
 })
-export class RemousResultsComponent extends ResultsComponentDirective implements DoCheck {
+export class RemousResultsComponent extends ResultsComponentDirective {
 
     private _remousResults: RemousResults;
 
@@ -43,23 +42,6 @@ export class RemousResultsComponent extends ResultsComponentDirective implements
      */
     private _tableHeaders: string[];
 
-    /**
-     * true si les résultats doivent être mis à jour
-     */
-    private _doUpdate = false;
-
-    /**
-     * composant des résultats variables
-     */
-    @ViewChild(VarResultsComponent)
-    private varResultsComponent: VarResultsComponent;
-
-    /**
-     * composant journal
-     */
-    @ViewChild(LogComponent)
-    private logComponent: LogComponent;
-
     constructor(
         private intlService: I18nService,
         private formService: FormulaireService
@@ -67,7 +49,11 @@ export class RemousResultsComponent extends ResultsComponentDirective implements
         super();
     }
 
-    private get uitextLigneFluviale() {
+    public get remousResults() {
+        return this._remousResults;
+    }
+
+    public get uitextLigneFluviale() {
         // calculator type for translation
         const sn = this._remousResults.result.sourceNub;
         let ct = sn.calcType;
@@ -77,7 +63,7 @@ export class RemousResultsComponent extends ResultsComponentDirective implements
         return this.formService.expandVariableNameAndUnit(ct, "FLU");
     }
 
-    private get uitextLigneTorrentielle() {
+    public get uitextLigneTorrentielle() {
         // calculator type for translation
         const sn = this._remousResults.result.sourceNub;
         let ct = sn.calcType;
@@ -87,23 +73,23 @@ export class RemousResultsComponent extends ResultsComponentDirective implements
         return this.formService.expandVariableNameAndUnit(ct, "TOR");
     }
 
-    private get uitextAbscisse() {
+    public get uitextAbscisse() {
         return this.intlService.localizeText("INFO_REMOUSRESULTS_ABSCISSE");
     }
 
-    private get uitextFond() {
+    public get uitextFond() {
         return this.intlService.localizeText("INFO_REMOUSRESULTS_FOND");
     }
 
-    private get uitextBerge() {
+    public get uitextBerge() {
         return this.intlService.localizeText("INFO_REMOUSRESULTS_BERGE");
     }
 
-    private get uitextTirantNormal() {
+    public get uitextTirantNormal() {
         return this.intlService.localizeText("INFO_REMOUSRESULTS_TIRANTNORMAL");
     }
 
-    private get uitextTirantCritique() {
+    public get uitextTirantCritique() {
         return this.intlService.localizeText("INFO_REMOUSRESULTS_TIRANTCRITIQUE");
     }
 
@@ -149,6 +135,7 @@ export class RemousResultsComponent extends ResultsComponentDirective implements
         return this._remousResults && this._remousResults.result && this._remousResults.result.ok;
     }
 
+    @Input()
     public set results(rs: CalculatorResults[]) {
         this._remousResults = undefined;
         if (rs !== undefined) {
@@ -159,43 +146,19 @@ export class RemousResultsComponent extends ResultsComponentDirective implements
                 }
             }
         }
-        this.updateView();
+        // this.updateView();
     }
 
-    public updateView() {
-        this.graph1_data = {};
-        this.graph1_options = {};
-        this.graph2_data = {};
-        this.graph2_options = {};
-        if (this.varResultsComponent !== undefined) {
-            this.varResultsComponent.results = undefined;
-        }
-        if (this.logComponent !== undefined) {
-            this.logComponent.log = undefined;
-        }
-        this._tableHeaders = [];
-
+    public get log(): cLog {
         if (this._remousResults !== undefined) {
-            this._doUpdate = this._remousResults.hasResults;
-        }
-    }
-
-    /**
-     * appelé pour gérer les changements non détectés par Angular
-     */
-    public ngDoCheck() {
-        if (this._doUpdate) {
-            this._doUpdate = !this.updateResults();
+            return this._remousResults.log;
         }
     }
 
-    private updateResults() {
-        if (this.logComponent !== undefined && this._remousResults !== undefined) {
-            this.logComponent.log = this._remousResults.log;
-            this.generateChart();
-            return true;
+    public get varResults(): VarResults {
+        if (this._remousResults !== undefined) {
+            return this._remousResults.varResults;
         }
-        return false;
     }
 
     /**
@@ -270,9 +233,6 @@ export class RemousResultsComponent extends ResultsComponentDirective implements
         // le dernier dataset de la liste datasets est dessiné en 1er
 
         this._remousResults.update();
-        if (this.varResultsComponent) {
-            this.varResultsComponent.results = this._remousResults.varResults;
-        }
 
         const nub = this._remousResults.result.sourceNub as CourbeRemous;
         const params = nub.prms as CourbeRemousParams;
diff --git a/src/app/components/results-chart/results-chart.component.ts b/src/app/components/results-chart/results-chart.component.ts
index 05247e41c..cda71306f 100644
--- a/src/app/components/results-chart/results-chart.component.ts
+++ b/src/app/components/results-chart/results-chart.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, AfterContentInit, ChangeDetectorRef } from "@angular/core";
+import { Component, ViewChild, AfterContentInit, ChangeDetectorRef, Input, OnChanges, SimpleChanges } from "@angular/core";
 
 import { ChartComponent } from "angular2-chartjs";
 
@@ -90,6 +90,7 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
         };
     }
 
+    @Input()
     public set results(r: PlottableData) {
         this.forceRebuild();
         this._results = r;
@@ -98,13 +99,13 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
         }
     }
 
-    public get availableXAxis() {
+    public get availableXAxis(): string[] {
         if (this._results) {
             return this._results.getAvailableXAxis();
         }
     }
 
-    public get availableYAxis() {
+    public get availableYAxis(): string[] {
         if (this._results) {
             if (this._results.graphType !== ChartType.Scatter) {
                 // do not use real Y axis (that include families), if chart cannot display multiple series
@@ -170,6 +171,7 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
     }
 
     public updateView() {
+        console.log("----> regenerate chart !!");
         // (re)generate chart
         switch (this._graphTypeComponent.selectedValue) {
             case ChartType.Histogram:
diff --git a/src/app/components/section-results/section-results.component.ts b/src/app/components/section-results/section-results.component.ts
index 99df6bb4a..5d6acdeee 100644
--- a/src/app/components/section-results/section-results.component.ts
+++ b/src/app/components/section-results/section-results.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, DoCheck, ElementRef } from "@angular/core";
+import { Component, ViewChild, ElementRef, Input } from "@angular/core";
 
 import { ResultElement } from "jalhyd";
 
@@ -16,7 +16,7 @@ import { FixedVarResultsComponent } from "../fixedvar-results/fixedvar-results.c
         "./section-results.component.scss"
     ]
 })
-export class SectionResultsComponent extends FixedVarResultsComponent implements DoCheck {
+export class SectionResultsComponent extends ResultsComponentDirective {
 
     constructor(
         private intlService: I18nService,
@@ -25,6 +25,7 @@ export class SectionResultsComponent extends FixedVarResultsComponent implements
         super();
     }
 
+    @Input()
     public set results(rs: CalculatorResults[]) {
         super.results = rs;
         this._resultElement = undefined;
@@ -36,7 +37,8 @@ export class SectionResultsComponent extends FixedVarResultsComponent implements
                 }
             }
         }
-        this.updateView();
+        // this.updateView();
+        this.drawSectionCanvas();
     }
 
     /** détermine s'il y a des résultats de section "fixes" (pas de paramètre varié, graphique de la section) */
@@ -72,16 +74,6 @@ export class SectionResultsComponent extends FixedVarResultsComponent implements
     @ViewChild(SectionCanvasComponent)
     private _sectionCanvasComponent: SectionCanvasComponent;
 
-    public updateView() {
-        if (this._sectionCanvasComponent) {
-            this._sectionCanvasComponent.reset();
-        }
-        if (this._results) {
-            this._doUpdate = this._results.hasResults;
-        }
-        super.updateView();
-    }
-
     private isSectionLevel(s: string) {
         for (const k in SectionResultsComponent.labelColors) {
             if (k === s) {
@@ -91,10 +83,11 @@ export class SectionResultsComponent extends FixedVarResultsComponent implements
         return false;
     }
 
-    protected updateResults() {
-        const superUpdated = super.updateResults();
+    private drawSectionCanvas() {
+        if (this._results && this._sectionCanvas) {
+
+            this._sectionCanvas.reset();
 
-        if (this._results && this._sectionCanvasComponent !== undefined) {
             this._resultElement = new ResultElement();
 
             // compute canvas optimal size the first time
diff --git a/src/app/components/variable-results-selector/variable-results-selector.component.ts b/src/app/components/variable-results-selector/variable-results-selector.component.ts
index ff36f82b1..716d7fc9e 100644
--- a/src/app/components/variable-results-selector/variable-results-selector.component.ts
+++ b/src/app/components/variable-results-selector/variable-results-selector.component.ts
@@ -1,11 +1,11 @@
-import { Component, Output, EventEmitter } from "@angular/core";
+import { Component, Output, EventEmitter, Input, OnChanges } from "@angular/core";
 
 import { I18nService } from "../../services/internationalisation.service";
 import { fv, longestVarParam } from "../../util";
 import { MultiDimensionResults } from "../../results/multidimension-results";
 import { PrebarrageResults } from "../../results/prebarrage-results";
 
-import { CalculatorType, PbCloison, Structure } from "jalhyd";
+import { CalculatorType, PbCloison, Structure, VariatedDetails } from "jalhyd";
 
 @Component({
     selector: "variable-results-selector",
@@ -14,12 +14,18 @@ import { CalculatorType, PbCloison, Structure } from "jalhyd";
         "./variable-results-selector.component.scss"
     ]
 })
-export class VariableResultsSelectorComponent {
+export class VariableResultsSelectorComponent implements OnChanges {
 
     /** résultats non mis en forme */
-    private _results: MultiDimensionResults;
+    @Input()
+    private results: MultiDimensionResults;
 
-    private _selectedValue: number;
+    /** détails des paramètres qui varient dans le Nub associé au formulaire */
+    @Input()
+    private variatedParameters: VariatedDetails[];
+
+    /** valeur en cours */
+    private _selectedValue = 0;
 
     /** size of the longest variable value */
     private size = 0;
@@ -27,26 +33,23 @@ export class VariableResultsSelectorComponent {
     /** inferred extended values list for each variating parameter */
     private varValues = [];
 
-    @Output()
-    protected indexChange = new EventEmitter();
+    /* @Output()
+    protected indexChange = new EventEmitter(); */
 
     constructor(
         protected intlService: I18nService,
-    ) {
-        this._selectedValue = 0;
-    }
+    ) { }
 
-    public set results(r: MultiDimensionResults) {
-        this._results = r;
-
-        if (this._results) {
-            // pre-extract variable parameters values
+    public ngOnChanges() {
+        console.log("==//== changes !! ==//==", this.variatedParameters);
+        // rebuild variable parameters values everytime somthing changes
+        if (this.variatedParameters) {
             this.varValues = [];
             // find longest list
-            const lvp = longestVarParam(this._results.variatedParameters);
+            const lvp = longestVarParam(this.variatedParameters);
             this.size = lvp.size;
             // get extended values lists for each variable parameter
-            for (const v of this._results.variatedParameters) {
+            for (const v of this.variatedParameters) {
                 const vv = [];
                 const iter = v.param.getExtendedValuesIterator(this.size);
                 while (iter.hasNext) {
@@ -56,13 +59,17 @@ export class VariableResultsSelectorComponent {
                 this.varValues.push(vv);
             }
         }
+        // get current variatedIndex even if component was rebuilt
+        if (this.results) {
+            this._selectedValue = this.results.variableIndex;
+        }
     }
 
     public get hasVariableResults(): boolean {
         return (
-            this._results
-            && this._results.hasResults
-            && this._results.variatedParameters.length > 0
+            this.results
+            && this.results.hasResults
+            && this.results.variatedParameters.length > 0
         );
     }
 
@@ -78,7 +85,7 @@ export class VariableResultsSelectorComponent {
         const kv = [];
         for (let i = 0; i < this.varValues.length; i++) {
             const vv = this.varValues[i];
-            const vp = this._results.variatedParameters[i];
+            const vp = this.results.variatedParameters[i];
             let symbol = vp.param.symbol;
             // is vp a parameter of a child Nub ?
             if (
@@ -90,7 +97,7 @@ export class VariableResultsSelectorComponent {
                 switch (vp.param.originNub.calcType) {
                     case CalculatorType.PreBarrage:
                         const struct = vp.param.parentNub as Structure;
-                        const pbRes = this._results as PrebarrageResults;
+                        const pbRes = this.results as PrebarrageResults;
                         const wall = struct.parent as PbCloison;
                         const posS = struct.findPositionInParent() + 1;
                         childPrefix = this.intlService.localizeMessage(wall.description);
@@ -117,8 +124,8 @@ export class VariableResultsSelectorComponent {
     }
 
     public set selectedValue(v: number) {
-        this._results.variableIndex = v;
-        this.indexChange.emit();
+        this.results.variableIndex = v;
+        // this.indexChange.emit();
     }
 
     public get label() {
diff --git a/src/app/results/multidimension-results.ts b/src/app/results/multidimension-results.ts
index 44967427c..c7af4cc99 100644
--- a/src/app/results/multidimension-results.ts
+++ b/src/app/results/multidimension-results.ts
@@ -6,7 +6,7 @@ import { VariatedDetails } from "jalhyd";
 export class MultiDimensionResults extends CalculatedParamResults {
 
     /** paramètres variés */
-    public variatedParameters: VariatedDetails[];
+    public variatedParameters: VariatedDetails[] = [];
 
     /** index de la valeur du paramètre varié à afficher dans les résultats */
     protected _variableIndex = 0;
diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts
index 918d70845..b982233ef 100644
--- a/src/app/results/var-results.ts
+++ b/src/app/results/var-results.ts
@@ -13,7 +13,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData
     /**
      * paramètres variés
      */
-    private _variatedParams: VariatedDetails[];
+    private _variatedParams: VariatedDetails[] = [];
 
     /**
      * titre des colonnes des résultats variés
@@ -408,10 +408,10 @@ export class VarResults extends CalculatedParamResults implements PlottableData
      * When variable parameter or chart type changes, ensure the X / Y current values are still available
      */
     public resetDefaultAxisIfNeeded() {
-        if (! this.getAvailableXAxis().includes(this.chartX)) {
+        if (this.variatedParameters.length > 0 && ! this.getAvailableXAxis().includes(this.chartX)) {
             this.chartX = this.variatedParameters[0].param.symbol;
         }
-        if (! this.getAvailableYAxis().includes(this.chartY)) {
+        if (this.variatedParameters.length > 0 && ! this.getAvailableYAxis().includes(this.chartY)) {
             this.chartY = this.variatedParameters[0].param.symbol;
         }
     }
-- 
GitLab


From ff2886215724aafcae0d1ddcb5c2fd3da80b34a5 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Mon, 20 Jul 2020 10:00:53 +0200
Subject: [PATCH 03/12] Renamed graphType to chartType

---
 .../results-chart/results-chart.component.ts  | 40 +++++++++----------
 .../formulaire/definition/form-fixedvar.ts    |  4 +-
 src/app/results/plottable-data.ts             |  2 +-
 .../plottable-macrorugo-compound-results.ts   |  2 +-
 src/app/results/plottable-pab-results.ts      |  2 +-
 src/app/results/var-results.ts                |  4 +-
 6 files changed, 26 insertions(+), 28 deletions(-)

diff --git a/src/app/components/results-chart/results-chart.component.ts b/src/app/components/results-chart/results-chart.component.ts
index cda71306f..2995070a5 100644
--- a/src/app/components/results-chart/results-chart.component.ts
+++ b/src/app/components/results-chart/results-chart.component.ts
@@ -92,10 +92,9 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
 
     @Input()
     public set results(r: PlottableData) {
-        this.forceRebuild();
         this._results = r;
         if (this._results && this._graphTypeComponent) {
-            this._graphTypeComponent.selectedValue = r.graphType;
+            this._graphTypeComponent.selectedValue = r.chartType;
         }
     }
 
@@ -107,7 +106,7 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
 
     public get availableYAxis(): string[] {
         if (this._results) {
-            if (this._results.graphType !== ChartType.Scatter) {
+            if (this._results.chartType !== ChartType.Scatter) {
                 // do not use real Y axis (that include families), if chart cannot display multiple series
                 return this._results.getAvailableXAxis();
             } else {
@@ -172,24 +171,23 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
 
     public updateView() {
         console.log("----> regenerate chart !!");
-        // (re)generate chart
-        switch (this._graphTypeComponent.selectedValue) {
-            case ChartType.Histogram:
-                this.graph_type = "bar";
-                this.generateBarChart();
-                break;
-
-            case ChartType.Dots:
-                this.graph_type = "line";
-                this.generateLineChart();
-                break;
-
-            default:
-                this.graph_type = "scatter";
-                this.generateScatterChart();
-                break;
+            switch (this._graphTypeComponent.selectedValue) {
+                case ChartType.Histogram:
+                    this.graph_type = "bar";
+                    this.generateBarChart();
+                    break;
+
+                case ChartType.Dots:
+                    this.graph_type = "line";
+                    this.generateLineChart();
+                    break;
+
+                default:
+                    this.graph_type = "scatter";
+                    this.generateScatterChart();
+                    break;
+            }
         }
-    }
 
     public ngAfterContentInit() {
         this._graphTypeComponent.addObserver(this);
@@ -481,7 +479,7 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
     update(sender: any, data: any) {
         if (sender instanceof ChartTypeSelectComponent) {
             if (data.action === "graphTypeChanged") {
-                this._results.graphType = data.value;
+                this._results.chartType = data.value;
             }
         }
         this.updateView();
diff --git a/src/app/formulaire/definition/form-fixedvar.ts b/src/app/formulaire/definition/form-fixedvar.ts
index acd265fa2..7509e9bd5 100644
--- a/src/app/formulaire/definition/form-fixedvar.ts
+++ b/src/app/formulaire/definition/form-fixedvar.ts
@@ -50,8 +50,8 @@ export class FormulaireFixedVar extends FormulaireDefinition {
         }
     }
 
-    public set graphType(t: ChartType) {
-        this._varResults.graphType = t;
+    public set chartType(t: ChartType) {
+        this._varResults.chartType = t;
     }
 
     public get hasResults(): boolean {
diff --git a/src/app/results/plottable-data.ts b/src/app/results/plottable-data.ts
index bae4f7709..5df0f992f 100644
--- a/src/app/results/plottable-data.ts
+++ b/src/app/results/plottable-data.ts
@@ -7,7 +7,7 @@ import { ParamDefinition } from "jalhyd";
  */
 export interface PlottableData {
 
-    graphType: ChartType;
+    chartType: ChartType;
     chartX: string;
     chartY: string;
 
diff --git a/src/app/results/plottable-macrorugo-compound-results.ts b/src/app/results/plottable-macrorugo-compound-results.ts
index caf34a119..f98b337af 100644
--- a/src/app/results/plottable-macrorugo-compound-results.ts
+++ b/src/app/results/plottable-macrorugo-compound-results.ts
@@ -6,7 +6,7 @@ import { ParamDefinition } from "jalhyd";
 
 export class PlottableMacrorugoCompoundResults implements PlottableData {
 
-    public graphType: ChartType = ChartType.Scatter;
+    public chartType: ChartType = ChartType.Scatter;
     public chartX: string;
     public chartY: string;
 
diff --git a/src/app/results/plottable-pab-results.ts b/src/app/results/plottable-pab-results.ts
index 56ee01671..fc8235f32 100644
--- a/src/app/results/plottable-pab-results.ts
+++ b/src/app/results/plottable-pab-results.ts
@@ -7,7 +7,7 @@ import { ParamDefinition } from "jalhyd";
 
 export class PlottablePabResults implements PlottableData {
 
-    public graphType: ChartType = ChartType.Scatter;
+    public chartType: ChartType = ChartType.Scatter;
     public chartX: string;
     public chartY: string;
 
diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts
index b982233ef..312a66f1c 100644
--- a/src/app/results/var-results.ts
+++ b/src/app/results/var-results.ts
@@ -97,11 +97,11 @@ export class VarResults extends CalculatedParamResults implements PlottableData
         return this._resultHeaders;
     }
 
-    public get graphType(): ChartType {
+    public get chartType(): ChartType {
         return this._graphType;
     }
 
-    public set graphType(gt: ChartType) {
+    public set chartType(gt: ChartType) {
         this._graphType = gt;
         this.resetDefaultAxisIfNeeded();
     }
-- 
GitLab


From 11ccee87c1e5c44aaf79e9461813914e938d16b8 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Mon, 20 Jul 2020 10:24:38 +0200
Subject: [PATCH 04/12] Simplified form results reset

---
 .../calculator-results.component.ts           |  6 +---
 .../calculator.component.ts                   | 35 +------------------
 .../pab-results/pab-results.component.ts      |  1 -
 .../pb-results/pb-results.component.ts        |  1 -
 .../remous-results.component.ts               |  1 -
 .../section-results.component.ts              |  1 -
 .../formulaire/definition/form-definition.ts  | 12 -------
 7 files changed, 2 insertions(+), 55 deletions(-)

diff --git a/src/app/components/calculator-results/calculator-results.component.ts b/src/app/components/calculator-results/calculator-results.component.ts
index 27fa0e724..8d6de93b5 100644
--- a/src/app/components/calculator-results/calculator-results.component.ts
+++ b/src/app/components/calculator-results/calculator-results.component.ts
@@ -20,7 +20,7 @@ export class CalculatorResultsComponent implements AfterViewChecked {
         @Inject(forwardRef(() => GenericCalculatorComponent)) private calculatorComponent: GenericCalculatorComponent
     ) { }
 
-    // @TODO this system is sh*tty !
+    // @TODO @Input() ?
     public set formulaire(f: FormulaireDefinition) {
         this._formulaire = f;
     }
@@ -33,10 +33,6 @@ export class CalculatorResultsComponent implements AfterViewChecked {
         return r;
     }
 
-    public updateView() {
-        console.log("UPDATE VIEW (disabled)");
-    }
-
     public ngAfterViewChecked() {
         this.afterViewChecked.emit();
     }
diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts
index 4951178b6..2be2d3286 100644
--- a/src/app/components/generic-calculator/calculator.component.ts
+++ b/src/app/components/generic-calculator/calculator.component.ts
@@ -388,10 +388,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
         this.appComponent.showProgressBar = true;
         this._computeClicked = true;
         this.showPBInputData = false;
-        // send resetForm to clear log
-        this._formulaire.notifyObservers({
-            "action": "resetForm",
-        }, this._formulaire);
         // calculate module
         setTimeout(() => {
             this._formulaire.doCompute();
@@ -443,22 +439,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
         }
     }
 
-    private setForm(f: FormulaireDefinition) {
-        if (this._formulaire !== undefined) {
-            this._formulaire.removeObserver(this);
-        }
-        this._formulaire = f;
-        if (this._formulaire !== undefined) {
-            this._formulaire.addObserver(this);
-        }
-    }
-
-    private updateFormulaireResults(uid: string) {
-        if (this._formulaire.uid === uid) {
-            this.resultsComponent.updateView();
-        }
-    }
-
     // interface Observer
 
     update(sender: any, data: any): void {
@@ -466,22 +446,13 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
             switch (data["action"]) {
                 case "currentFormChanged":
                     const uid: string = data["formId"];
-                    this.setForm(this.formulaireService.getFormulaireFromId(uid));
+                    this._formulaire = (this.formulaireService.getFormulaireFromId(uid));
                     this.resultsComponent.formulaire = this._formulaire;
                     this._calculatorNameComponent.model = this._formulaire;
                     // reload localisation in all cases (it does not eat bread)
                     this.formulaireService.updateFormulaireLocalisation(this._formulaire);
                     break;
             }
-        } else if (sender instanceof FormulaireDefinition) {
-            let f: FormulaireDefinition;
-            switch (data["action"]) {
-                case "resetForm": // réinitialisation du formulaire
-                case "resultsUpdated":
-                    f = sender as FormulaireDefinition;
-                    this.updateFormulaireResults(f.uid);
-                    break;
-            }
         }
     }
 
@@ -557,8 +528,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
      */
     public onInputChange(event: any) {
         this._formulaire.resetResults([], (event ? event.symbol : undefined));
-        // to refresh log components, that are fed manually (!)
-        this.resultsComponent.updateView();
     }
 
     /**
@@ -604,8 +573,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
         // show proper form (actually subform elements) or proper results,
         // depending on what was clicked
         (this._formulaire as FormulairePrebarrage).nodeSelected(event.node);
-        // refresh results component
-        this.resultsComponent.updateView();
     }
 
     public openHelp() {
diff --git a/src/app/components/pab-results/pab-results.component.ts b/src/app/components/pab-results/pab-results.component.ts
index 011ba0bd1..513710980 100644
--- a/src/app/components/pab-results/pab-results.component.ts
+++ b/src/app/components/pab-results/pab-results.component.ts
@@ -37,7 +37,6 @@ export class PabResultsComponent extends ResultsComponentDirective {
         if (rs.length > 0 && rs[0] instanceof PabResults) {
             this._pabResults = rs[0] as PabResults;
         }
-        // this.updateView();
     }
 
     private mergeGlobalLog(result: Result, log: cLog) {
diff --git a/src/app/components/pb-results/pb-results.component.ts b/src/app/components/pb-results/pb-results.component.ts
index 666257c7d..034f24e0c 100644
--- a/src/app/components/pb-results/pb-results.component.ts
+++ b/src/app/components/pb-results/pb-results.component.ts
@@ -30,7 +30,6 @@ export class PbResultsComponent {
                 this._pbResults = r as PrebarrageResults;
             }
         }
-        // this.updateView();
     }
 
     public get pbResults() {
diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts
index 4a18b7fb9..5762459e1 100644
--- a/src/app/components/remous-results/remous-results.component.ts
+++ b/src/app/components/remous-results/remous-results.component.ts
@@ -146,7 +146,6 @@ export class RemousResultsComponent extends ResultsComponentDirective {
                 }
             }
         }
-        // this.updateView();
     }
 
     public get log(): cLog {
diff --git a/src/app/components/section-results/section-results.component.ts b/src/app/components/section-results/section-results.component.ts
index 5d6acdeee..8590e0248 100644
--- a/src/app/components/section-results/section-results.component.ts
+++ b/src/app/components/section-results/section-results.component.ts
@@ -37,7 +37,6 @@ export class SectionResultsComponent extends ResultsComponentDirective {
                 }
             }
         }
-        // this.updateView();
         this.drawSectionCanvas();
     }
 
diff --git a/src/app/formulaire/definition/form-definition.ts b/src/app/formulaire/definition/form-definition.ts
index eb1dc8ad5..9ebc4348b 100644
--- a/src/app/formulaire/definition/form-definition.ts
+++ b/src/app/formulaire/definition/form-definition.ts
@@ -317,12 +317,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
         }
     }
 
-    protected notifyReset() {
-        this.notifyObservers({
-            "action": "resetForm"
-        }, this);
-    }
-
     /**
      * Forwards Nub's progress updated notification.
      * Used by CalculatorComponent to update progress bar
@@ -337,8 +331,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
      */
     public reset() {
         this.resetResults([], undefined, true);
-        // prévenir les composants qu'il faut détecter les changements
-        this.notifyReset();
     }
 
     /**
@@ -499,10 +491,6 @@ export abstract class FormulaireDefinition extends FormulaireNode implements Obs
     public doCompute() {
         // calculate module
         this.compute();
-        // refresh results
-        this.notifyObservers({
-            "action": "resultsUpdated",
-        }, this);
     }
 
     public resetFormResults() {}
-- 
GitLab


From bf8654f75e896d9d56a50aa3aeada5458a22cdc7 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Mon, 20 Jul 2020 11:30:44 +0200
Subject: [PATCH 05/12] Simplified results charts components

---
 .../fixedvar-results.component.html           |  2 +-
 .../fixedvar-results.component.ts             |  2 +-
 .../jet-results/jet-results.component.html    |  4 +-
 .../jet-trajectory-chart.component.ts         | 30 +++++++-------
 .../macrorugo-compound-results.component.html |  8 ++--
 .../macrorugo-compound-results.component.ts   |  9 ++---
 .../pab-profile-chart.component.ts            | 12 +++---
 .../pab-results/pab-results.component.html    |  3 +-
 .../results-chart/results-chart.component.ts  | 40 ++++++++++---------
 .../formulaire/definition/form-pb-cloison.ts  |  2 -
 src/app/results/param-calc-results.ts         |  9 -----
 src/app/results/plottable-data.ts             |  5 +++
 .../plottable-macrorugo-compound-results.ts   |  4 ++
 src/app/results/plottable-pab-results.ts      |  4 ++
 src/app/results/var-results.ts                | 29 +++++++++-----
 15 files changed, 85 insertions(+), 78 deletions(-)

diff --git a/src/app/components/fixedvar-results/fixedvar-results.component.html b/src/app/components/fixedvar-results/fixedvar-results.component.html
index 6c2d779be..271a25508 100644
--- a/src/app/components/fixedvar-results/fixedvar-results.component.html
+++ b/src/app/components/fixedvar-results/fixedvar-results.component.html
@@ -2,7 +2,7 @@
     <!-- journal -->
     <log [log]=mergedGlobalLogs></log>
 
-    <results-chart [hidden]="! showVarResultsChart" [results]=varResults></results-chart>
+    <results-chart [hidden]="! showVarResultsChart" [results]=varResults [resultData]=varResults?.result></results-chart>
 
     <div>
         <!-- table des résultats fixés -->
diff --git a/src/app/components/fixedvar-results/fixedvar-results.component.ts b/src/app/components/fixedvar-results/fixedvar-results.component.ts
index b80300bad..d93bcc55c 100644
--- a/src/app/components/fixedvar-results/fixedvar-results.component.ts
+++ b/src/app/components/fixedvar-results/fixedvar-results.component.ts
@@ -74,7 +74,7 @@ export class FixedVarResultsComponent extends ResultsComponentDirective {
      * affichage du graphique des résultats variés
      */
     public get showVarResultsChart(): boolean {
-        return this._varResults && this._varResults.hasPlottableResults;
+        return this._varResults && this._varResults.hasPlottableResults();
     }
 
     public getFixedResultClass(i: number) {
diff --git a/src/app/components/jet-results/jet-results.component.html b/src/app/components/jet-results/jet-results.component.html
index 1acaf47ff..f3680821b 100644
--- a/src/app/components/jet-results/jet-results.component.html
+++ b/src/app/components/jet-results/jet-results.component.html
@@ -2,9 +2,9 @@
     <!-- journal -->
     <log></log>
 
-    <results-chart *ngIf="showVarResults" [hidden]="! showVarResultsChart" [results]=varResults></results-chart>
+    <results-chart *ngIf="showVarResults" [hidden]="! showVarResultsChart" [results]=varResults [resultData]=varResults?.result></results-chart>
 
-    <jet-trajectory-chart [hidden]="! hasValidResults" [results]=trajectoryResults></jet-trajectory-chart>
+    <jet-trajectory-chart [hidden]="! hasValidResults" [results]=trajectoryResults?.result></jet-trajectory-chart>
 
     <div>
         <!-- table des résultats fixés -->
diff --git a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
index f4ee238a0..2f92d72ac 100644
--- a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
+++ b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
@@ -1,16 +1,14 @@
-import { Component, ViewChild, ChangeDetectorRef, Input } from "@angular/core";
+import { Component, ViewChild, ChangeDetectorRef, Input, OnChanges } from "@angular/core";
 
 import { ChartComponent } from "angular2-chartjs";
 
 import { I18nService } from "../../services/internationalisation.service";
 import { ResultsComponentDirective } from "../fixedvar-results/results.component";
 import { IYSeries } from "../../results/y-series";
-import { FixedResults } from "../../results/fixed-results";
-import { VarResults } from "../../results/var-results";
 import { fv } from "../../util";
 import { AppComponent } from "../../app.component";
 
-import { Jet } from "jalhyd";
+import { Jet, Result } from "jalhyd";
 
 @Component({
     selector: "jet-trajectory-chart",
@@ -19,12 +17,12 @@ import { Jet } from "jalhyd";
         "./jet-trajectory-chart.component.scss"
     ]
 })
-export class JetTrajectoryChartComponent extends ResultsComponentDirective {
+export class JetTrajectoryChartComponent extends ResultsComponentDirective implements OnChanges {
 
     @ViewChild(ChartComponent)
     private chartComponent;
 
-    private _results: FixedResults | VarResults;
+    private _results: Result;
 
     private _zoomWasChanged = false;
 
@@ -133,13 +131,17 @@ export class JetTrajectoryChartComponent extends ResultsComponentDirective {
     }
 
     @Input()
-    public set results(r: FixedResults | VarResults) {
+    public set results(r: Result) {
         console.log("miam miam les bons résultats !", r);
         this.forceRebuild(); // used for forcing redefinition of xAxes[0].ticks.min/max in generateScatterChart()
         this._results = r;
+    }
 
-        if (this._results && this._results.result) {
-            const nub = this._results.result.sourceNub as Jet;
+    // redessine le graphique dès qu'une entrée change
+    public ngOnChanges() {
+        console.log("----> regenerate trajectory chart !!");
+        if (this._results) {
+            const nub = this._results.sourceNub as Jet;
             const length = nub.variatingLength();
             // extract variable values list for legend
             if (nub.resultHasMultipleValues()) {
@@ -160,6 +162,7 @@ export class JetTrajectoryChartComponent extends ResultsComponentDirective {
                     }
                 }
             }
+            this.generateScatterChart();
         }
     }
 
@@ -172,17 +175,12 @@ export class JetTrajectoryChartComponent extends ResultsComponentDirective {
         return this._zoomWasChanged;
     }
 
-    public updateView() {
-        console.log("----> regenerate trajectory chart !!");
-        this.generateScatterChart();
-    }
-
     /**
      * génère les données d'un graphique de type "scatter"
      */
     private generateScatterChart() {
         const ySeries = this.getYSeries();
-        const nub = (this._results.result.sourceNub as Jet);
+        const nub = (this._results.sourceNub as Jet);
 
         this.graph_data = {
             datasets: []
@@ -263,7 +261,7 @@ export class JetTrajectoryChartComponent extends ResultsComponentDirective {
     private getYSeries(): IYSeries[] {
         const ret: IYSeries[] = [];
         const palette = ResultsComponentDirective.distinctColors;
-        const nub = (this._results.result.sourceNub as Jet);
+        const nub = (this._results.sourceNub as Jet);
         const trajectories = nub.generateTrajectories();
 
         for (let i = 0; i < trajectories.length; i++) {
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
index ed2f042bc..9ce5cecca 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
@@ -21,11 +21,9 @@
     <quicknav *ngIf="hasDisplayableResults" [items]="[ 'input', 'results', 'charts' ]" [currentItem]="'charts'"
         [align]="'left'"></quicknav>
 
-    <div id="macrorugo-compound-graphs-container" class="container" fxLayout="row wrap"
-        fxLayoutAlign="space-around start">
-        <!-- <pab-profile-chart *ngIf="hasDisplayableResults" fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
-        </pab-profile-chart> -->
-        <results-chart *ngIf="hasDisplayableResults" [results]=plottableResults fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
+    <div id="macrorugo-compound-graphs-container" class="container" fxLayout="row wrap" fxLayoutAlign="space-around start">
+        <results-chart *ngIf="hasDisplayableResults" [results]=plottableResults [resultData]=plottableResults?.result
+          fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </results-chart>
     </div>
 
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
index cbe53d860..d59d27a3f 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
@@ -25,15 +25,11 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
     /** résultats non mis en forme */
     private _mrcResults: MacrorugoCompoundResults;
 
-    /** résultats mis en forme pour le graphique de données (classique) */
-    private _plottableResults: PlottableMacrorugoCompoundResults;
-
     constructor(
         private appSetupService: ApplicationSetupService,
         private i18nService: I18nService,
     ) {
         super();
-        this._plottableResults = new PlottableMacrorugoCompoundResults();
     }
 
     public ngOnChanges() {
@@ -234,8 +230,9 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
 
     /** builds a set of PlottableData from MacrorugoCompoundResults, to feed the chart */
     protected get plottableResults(): PlottableData {
-        this._plottableResults.setMrcResults(this.mrcResults);
-        return this._plottableResults;
+        const plottableResults = new PlottableMacrorugoCompoundResults();
+        plottableResults.setMrcResults(this.mrcResults);
+        return plottableResults;
     }
 
 }
diff --git a/src/app/components/pab-profile-chart/pab-profile-chart.component.ts b/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
index 6f24b8ab1..9e4e3ba5e 100644
--- a/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
+++ b/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, ChangeDetectorRef, Input } from "@angular/core";
+import { Component, ViewChild, ChangeDetectorRef, Input, OnChanges } from "@angular/core";
 
 import { ChartComponent } from "angular2-chartjs";
 
@@ -20,7 +20,7 @@ import { sprintf } from "sprintf-js";
         "./pab-profile-chart.component.scss"
     ]
 })
-export class PabProfileChartComponent extends ResultsComponentDirective {
+export class PabProfileChartComponent extends ResultsComponentDirective implements OnChanges {
 
     @ViewChild(ChartComponent)
     private chartComponent;
@@ -128,7 +128,10 @@ export class PabProfileChartComponent extends ResultsComponentDirective {
     @Input()
     public set results(r: PabResults) {
         this._results = r;
+    }
 
+    // redessine le graphique dès qu'une entrée change
+    public ngOnChanges() {
         // pre-extract variable parameters values
         if (this._results) {
             this.varValues = [];
@@ -146,6 +149,7 @@ export class PabProfileChartComponent extends ResultsComponentDirective {
                 this.varValues.push(vv);
             }
         }
+        this.generateScatterChart();
     }
 
     public zoomComplete() {
@@ -157,10 +161,6 @@ export class PabProfileChartComponent extends ResultsComponentDirective {
         return this._zoomWasChanged;
     }
 
-    public updateView() {
-        this.generateScatterChart();
-    }
-
     /**
      * génère les données d'un graphique de type "scatter"
      */
diff --git a/src/app/components/pab-results/pab-results.component.html b/src/app/components/pab-results/pab-results.component.html
index 8dc980039..225c00f9e 100644
--- a/src/app/components/pab-results/pab-results.component.html
+++ b/src/app/components/pab-results/pab-results.component.html
@@ -20,7 +20,8 @@
     <div id="pab-graphs-container" class="container" fxLayout="row wrap" fxLayoutAlign="space-around start">
         <pab-profile-chart *ngIf="hasDisplayableResults" [results]=pabResults fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </pab-profile-chart>
-        <results-chart *ngIf="hasDisplayableResults" [results]=plottableResults fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
+        <results-chart *ngIf="hasDisplayableResults" [results]=plottableResults [resultData]=plottableResults?.result
+          fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </results-chart>
     </div>
 
diff --git a/src/app/components/results-chart/results-chart.component.ts b/src/app/components/results-chart/results-chart.component.ts
index 2995070a5..2dd547434 100644
--- a/src/app/components/results-chart/results-chart.component.ts
+++ b/src/app/components/results-chart/results-chart.component.ts
@@ -1,8 +1,8 @@
-import { Component, ViewChild, AfterContentInit, ChangeDetectorRef, Input, OnChanges, SimpleChanges } from "@angular/core";
+import { Component, ViewChild, AfterContentInit, ChangeDetectorRef, Input, OnChanges } from "@angular/core";
 
 import { ChartComponent } from "angular2-chartjs";
 
-import { Observer, ParamFamily } from "jalhyd";
+import { Observer, ParamFamily, Result } from "jalhyd";
 
 import { ChartTypeSelectComponent } from "./chart-type.component";
 import { I18nService } from "../../services/internationalisation.service";
@@ -21,7 +21,7 @@ import { AppComponent } from "../../app.component";
         "./results-chart.component.scss"
     ]
 })
-export class ResultsChartComponent extends ResultsComponentDirective implements AfterContentInit, Observer {
+export class ResultsChartComponent extends ResultsComponentDirective implements AfterContentInit, Observer, OnChanges {
 
     @ViewChild(ChartComponent)
     private chartComponent;
@@ -98,6 +98,11 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
         }
     }
 
+    @Input()
+    public set resultData(r: Result) {
+        // trick to trigger onChanges when results data changes
+    }
+
     public get availableXAxis(): string[] {
         if (this._results) {
             return this._results.getAvailableXAxis();
@@ -124,9 +129,8 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
     public set chartX(X) {
         if (X !== this.chartX) {
             this._results.chartX = X;
-            this.forceRebuild();
             // refresh chart
-            this.updateView();
+            this.drawChart();
         }
     }
 
@@ -139,9 +143,8 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
     public set chartY(Y) {
         if (Y !== this.chartY) {
             this._results.chartY = Y;
-            this.forceRebuild();
             // refresh chart
-            this.updateView();
+            this.drawChart();
         }
     }
 
@@ -169,8 +172,15 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
         return this._zoomWasChanged;
     }
 
-    public updateView() {
-        console.log("----> regenerate chart !!");
+    public ngOnChanges() {
+        console.log("==> ResChart onChanges");
+        // redessiner le graphique chaque fois qu'une entrée change
+        this.drawChart();
+    }
+
+    public drawChart() {
+        console.log("----> regenerate chart !!", this._results);
+        if (this._results && this._results.hasPlottableResults()) {
             switch (this._graphTypeComponent.selectedValue) {
                 case ChartType.Histogram:
                     this.graph_type = "bar";
@@ -188,6 +198,7 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
                     break;
             }
         }
+    }
 
     public ngAfterContentInit() {
         this._graphTypeComponent.addObserver(this);
@@ -212,15 +223,6 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
         return l;
     }
 
-    /** forces Angular to rebuild the chart @see bug #137 */
-    private forceRebuild() {
-        this.displayChart = false;
-        const that = this;
-        setTimeout(() => { // trick
-            that.displayChart = true;
-        }, 10);
-    }
-
     /**
      * génère les données d'un graphique de type "bar"
      */
@@ -482,6 +484,6 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
                 this._results.chartType = data.value;
             }
         }
-        this.updateView();
+        this.drawChart();
     }
 }
diff --git a/src/app/formulaire/definition/form-pb-cloison.ts b/src/app/formulaire/definition/form-pb-cloison.ts
index b1599380c..311f8f918 100644
--- a/src/app/formulaire/definition/form-pb-cloison.ts
+++ b/src/app/formulaire/definition/form-pb-cloison.ts
@@ -122,8 +122,6 @@ export class FormulairePbCloison extends FormulaireParallelStructure {
     public reset() {
         // also reset parent results (that will reset all its children results)
         (this.parent as FormulairePrebarrage).reset();
-        // prévenir les composants qu'il faut détecter les changements
-        this.notifyReset();
     }
 
     // ensure all PBresults are reset
diff --git a/src/app/results/param-calc-results.ts b/src/app/results/param-calc-results.ts
index 6a2418848..eaca087d3 100644
--- a/src/app/results/param-calc-results.ts
+++ b/src/app/results/param-calc-results.ts
@@ -40,15 +40,6 @@ export abstract class CalculatedParamResults extends CalculatorResults {
             return false;
         }
         return true;
-        // return ! this.result.hasOnlyErrors;
-    }
-
-    /** return true if there is something to display on the variable results chart */
-    public get hasPlottableResults(): boolean {
-        if (this.result === undefined) {
-            return false;
-        }
-        return ! this.result.hasOnlyErrors;
     }
 
     public get hasLog(): boolean {
diff --git a/src/app/results/plottable-data.ts b/src/app/results/plottable-data.ts
index 5df0f992f..a2bd574d2 100644
--- a/src/app/results/plottable-data.ts
+++ b/src/app/results/plottable-data.ts
@@ -47,4 +47,9 @@ export interface PlottableData {
      * (used by tooltip functions)
      */
     getVariatingParametersSymbols(): string[];
+
+    /**
+     * Returns true if results contain data
+     */
+    hasPlottableResults(): boolean;
 }
diff --git a/src/app/results/plottable-macrorugo-compound-results.ts b/src/app/results/plottable-macrorugo-compound-results.ts
index f98b337af..ace4357c6 100644
--- a/src/app/results/plottable-macrorugo-compound-results.ts
+++ b/src/app/results/plottable-macrorugo-compound-results.ts
@@ -21,6 +21,10 @@ export class PlottableMacrorugoCompoundResults implements PlottableData {
         this.chartY = this.chartY || "Q";
     }
 
+    public hasPlottableResults(): boolean {
+        return this.mrcResults && this.mrcResults.hasResults;
+    }
+
     /** reaffect mrcResults, for ex. when objet was contructed with empty mrcResults */
     public setMrcResults(mrcResults: MacrorugoCompoundResults) {
         this.mrcResults = mrcResults;
diff --git a/src/app/results/plottable-pab-results.ts b/src/app/results/plottable-pab-results.ts
index fc8235f32..ad75a959e 100644
--- a/src/app/results/plottable-pab-results.ts
+++ b/src/app/results/plottable-pab-results.ts
@@ -22,6 +22,10 @@ export class PlottablePabResults implements PlottableData {
         this.chartY = this.chartY || "YMOY";
     }
 
+    public hasPlottableResults(): boolean {
+        return this.pabResults && this.pabResults.hasResults;
+    }
+
     /** reaffect pabResults, for ex. when objet was contructed with empty pabResults */
     public setPabResults(pabResults: PabResults) {
         this.pabResults = pabResults;
diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts
index 312a66f1c..7b85bfb0d 100644
--- a/src/app/results/var-results.ts
+++ b/src/app/results/var-results.ts
@@ -106,19 +106,28 @@ export class VarResults extends CalculatedParamResults implements PlottableData
         this.resetDefaultAxisIfNeeded();
     }
 
-    public getChartAxisLabel(symbol: string): string {
-        // 1. calculated param ?
-        if (this.calculatedParameter && this.calculatedParameter.symbol === symbol) {
-            return this.calculatedParameterHeader;
+    public hasPlottableResults(): boolean {
+        if (this.result === undefined) {
+            return false;
         }
-        // 2. variated param ?
-        for (let i = 0; i < this.variatedParameters.length; i++) {
-            if (this._variatedParams[i].param.symbol === symbol) {
-                return this.variableParamHeaders[i];
+        return ! this.result.hasOnlyErrors;
+    }
+
+    public getChartAxisLabel(symbol: string): string {
+        if (this.result) {
+            // 1. calculated param ?
+            if (this.calculatedParameter && this.calculatedParameter.symbol === symbol) {
+                return this.calculatedParameterHeader;
+            }
+            // 2. variated param ?
+            for (let i = 0; i < this.variatedParameters.length; i++) {
+                if (this._variatedParams[i].param.symbol === symbol) {
+                    return this.variableParamHeaders[i];
+                }
             }
+            // 3. Result element / child result
+            return this.expandLabelFromSymbol(new ParamDefinition(undefined, symbol, ParamDomainValue.ANY));
         }
-        // 3. Result element / child result
-        return this.expandLabelFromSymbol(new ParamDefinition(undefined, symbol, ParamDomainValue.ANY));
     }
 
     /**
-- 
GitLab


From d1bf33e2e1d4b411f5744adda5be415be7d17f49 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Mon, 20 Jul 2020 15:51:39 +0200
Subject: [PATCH 06/12] Simplified section canvas component

---
 src/app/app.module.ts                         |   2 -
 src/app/components/canvas/canvas.component.ts | 109 -------
 .../jet-trajectory-chart.component.ts         |   1 -
 .../macrorugo-compound-results.component.ts   |   2 +-
 .../pab-profile-chart.component.ts            |   2 +-
 .../remous-results.component.html             |   3 +-
 .../remous-results.component.ts               |  13 +-
 .../section-canvas.component.html             |   2 +
 .../section-canvas.component.scss             |   3 +
 .../section-canvas.component.ts               | 284 +++++++++++++-----
 .../section-results.component.html            |   2 +-
 .../section-results.component.ts              | 136 +++------
 12 files changed, 263 insertions(+), 296 deletions(-)
 delete mode 100644 src/app/components/canvas/canvas.component.ts
 create mode 100644 src/app/components/section-canvas/section-canvas.component.html
 create mode 100644 src/app/components/section-canvas/section-canvas.component.scss

diff --git a/src/app/app.module.ts b/src/app/app.module.ts
index 59f49747f..f1d0c0215 100644
--- a/src/app/app.module.ts
+++ b/src/app/app.module.ts
@@ -66,7 +66,6 @@ import { FixedVarResultsComponent } from "./components/fixedvar-results/fixedvar
 import { SectionResultsComponent } from "./components/section-results/section-results.component";
 import { GenericCalculatorComponent } from "./components/generic-calculator/calculator.component";
 import { CalculatorNameComponent } from "./components/generic-calculator/calc-name.component";
-import { CalcCanvasComponent } from "./components/canvas/canvas.component";
 import { SectionCanvasComponent } from "./components/section-canvas/section-canvas.component";
 import { RemousResultsComponent } from "./components/remous-results/remous-results.component";
 import { ResultsChartComponent } from "./components/results-chart/results-chart.component";
@@ -186,7 +185,6 @@ const appRoutes: Routes = [
         AppComponent,
         ApplicationSetupComponent,
         BaseParamInputComponent,
-        CalcCanvasComponent,
         CalculatorListComponent,
         CalculatorNameComponent,
         CalculatorResultsComponent,
diff --git a/src/app/components/canvas/canvas.component.ts b/src/app/components/canvas/canvas.component.ts
deleted file mode 100644
index 2035e886e..000000000
--- a/src/app/components/canvas/canvas.component.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import { Component, Input, ViewChild, ElementRef, AfterViewInit } from "@angular/core";
-
-@Component({
-    selector: "calc-canvas",
-    template: `<canvas #canvas
-    [attr.width]="width"
-    [attr.height]="height">
-    </canvas>
-    `
-})
-export class CalcCanvasComponent implements AfterViewInit {
-
-    public get width(): number {
-        return this._calcCanvas.nativeElement.width;
-    }
-
-    @Input()
-    public set width(w: number) {
-        this._calcCanvas.nativeElement.width = w;
-    }
-
-    public get height(): number {
-        return this._calcCanvas.nativeElement.height;
-    }
-
-    @Input()
-    public set height(h: number) {
-        this._calcCanvas.nativeElement.height = h;
-    }
-
-    private _context2d: CanvasRenderingContext2D;
-
-    @ViewChild("canvas", { static: true })
-    private _calcCanvas: ElementRef;
-
-    ngAfterViewInit() { // wait for the view to init before using the element
-        this._context2d = this._calcCanvas.nativeElement.getContext("2d");
-    }
-
-    public clear() {
-        if (this._context2d) {
-            this._context2d.clearRect(0, 0, this.width, this.height);
-        }
-    }
-
-    public setStrokeColor(r: number, g: number, b: number) {
-        const col: string = "rgb(" + r + "," + g + "," + b + ")";
-        this._context2d.strokeStyle = col;
-    }
-
-    public setFillColor(r: number, g: number, b: number) {
-        const col: string = "rgb(" + r + "," + g + "," + b + ")";
-        this._context2d.fillStyle = col;
-    }
-
-    public setFont(f: string) {
-        this._context2d.font = f;
-    }
-
-    public fillText(s: string, x: number, y: number, align?: any) {
-        if (align) {
-            this._context2d.textAlign = align;
-        }
-        this._context2d.fillText(s, x, y);
-    }
-
-    public setLineWidth(w: number) {
-        this._context2d.lineWidth = w;
-    }
-
-    public setLineDash(d: number[]) {
-        this._context2d.setLineDash(d);
-    }
-
-    public resetLineDash() {
-        this._context2d.setLineDash([]);
-    }
-
-    public drawRect(x1: number, y1: number, w: number, h: number) {
-        this._context2d.strokeRect(x1, y1, w, h);
-    }
-
-    public drawLine(x1: number, y1: number, x2: number, y2: number) {
-        this._context2d.beginPath();
-        this._context2d.moveTo(x1, y1);
-        this._context2d.lineTo(x2, y2);
-        this._context2d.stroke();
-    }
-
-    /**
-     *
-     * @param x The x axis of the coordinate for the ellipse's center.
-     * @param y The y axis of the coordinate for the ellipse's center.
-     * @param radiusX The ellipse's major-axis radius.
-     * @param radiusY The ellipse's minor-axis radius.
-     * @param rotation The rotation for this ellipse, expressed in radians
-     * @param startAngle The starting point, measured from the x axis, from which it will be drawn, expressed in radians
-     * @param endAngle The end ellipse's angle to which it will be drawn, expressed in radians
-     */
-    public drawEllipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number) {
-        this._context2d.beginPath();
-        this._context2d.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle);
-        this._context2d.stroke();
-    }
-
-    public get context2d(): CanvasRenderingContext2D {
-        return this._context2d;
-    }
-}
diff --git a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
index 2f92d72ac..3e4d1e9db 100644
--- a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
+++ b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
@@ -132,7 +132,6 @@ export class JetTrajectoryChartComponent extends ResultsComponentDirective imple
 
     @Input()
     public set results(r: Result) {
-        console.log("miam miam les bons résultats !", r);
         this.forceRebuild(); // used for forcing redefinition of xAxes[0].ticks.min/max in generateScatterChart()
         this._results = r;
     }
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
index d59d27a3f..6c17591e8 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
@@ -33,7 +33,7 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
     }
 
     public ngOnChanges() {
-        console.log("--------> MRCR_C changes…");
+        // console.log("--------> MRCR_C changes…");
     }
 
     @Input()
diff --git a/src/app/components/pab-profile-chart/pab-profile-chart.component.ts b/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
index 9e4e3ba5e..5d9220b27 100644
--- a/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
+++ b/src/app/components/pab-profile-chart/pab-profile-chart.component.ts
@@ -148,8 +148,8 @@ export class PabProfileChartComponent extends ResultsComponentDirective implemen
                 }
                 this.varValues.push(vv);
             }
+            this.generateScatterChart();
         }
-        this.generateScatterChart();
     }
 
     public zoomComplete() {
diff --git a/src/app/components/remous-results/remous-results.component.html b/src/app/components/remous-results/remous-results.component.html
index da5ce69b5..7f9efd5fd 100644
--- a/src/app/components/remous-results/remous-results.component.html
+++ b/src/app/components/remous-results/remous-results.component.html
@@ -44,8 +44,7 @@
 <!-- journal -->
 <log [log]=log></log>
 
-<div [hidden]="! hasData">
-    <!-- *ngIf breaks @ViewChild availability-->
+<div *ngIf="hasData">
     <!-- résultats numériques -->
     <var-results [results]=varResults></var-results>
 </div>
diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts
index 5762459e1..532556c37 100644
--- a/src/app/components/remous-results/remous-results.component.ts
+++ b/src/app/components/remous-results/remous-results.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input } from "@angular/core";
+import { Component, Input, OnChanges, SimpleChanges } from "@angular/core";
 
 import { INumberIterator, CourbeRemousParams, CourbeRemous, ParamDefinition, ParamDomainValue, cLog } from "jalhyd";
 
@@ -19,7 +19,7 @@ import { VarResults } from "../../results/var-results";
         "./remous-results.component.scss"
     ]
 })
-export class RemousResultsComponent extends ResultsComponentDirective {
+export class RemousResultsComponent extends ResultsComponentDirective implements OnChanges {
 
     private _remousResults: RemousResults;
 
@@ -148,6 +148,13 @@ export class RemousResultsComponent extends ResultsComponentDirective {
         }
     }
 
+    public ngOnChanges(s: SimpleChanges) {
+        // console.log("_________> RRC onChanges", s);
+        if (this._remousResults && this._remousResults.result) {
+            this.generateChart();
+        }
+    }
+
     public get log(): cLog {
         if (this._remousResults !== undefined) {
             return this._remousResults.log;
@@ -230,7 +237,7 @@ export class RemousResultsComponent extends ResultsComponentDirective {
     private generateChart() {
         // http://www.chartjs.org/docs/latest/charts/line.html
         // le dernier dataset de la liste datasets est dessiné en 1er
-
+        console.log("ooOOO Oui !");
         this._remousResults.update();
 
         const nub = this._remousResults.result.sourceNub as CourbeRemous;
diff --git a/src/app/components/section-canvas/section-canvas.component.html b/src/app/components/section-canvas/section-canvas.component.html
new file mode 100644
index 000000000..da242b966
--- /dev/null
+++ b/src/app/components/section-canvas/section-canvas.component.html
@@ -0,0 +1,2 @@
+<canvas #canvas [attr.width]="width" [attr.height]="height">
+</canvas>
diff --git a/src/app/components/section-canvas/section-canvas.component.scss b/src/app/components/section-canvas/section-canvas.component.scss
new file mode 100644
index 000000000..7f26ddcb5
--- /dev/null
+++ b/src/app/components/section-canvas/section-canvas.component.scss
@@ -0,0 +1,3 @@
+:host {
+    display: block;
+}
diff --git a/src/app/components/section-canvas/section-canvas.component.ts b/src/app/components/section-canvas/section-canvas.component.ts
index 3475f8842..81b4c45dd 100644
--- a/src/app/components/section-canvas/section-canvas.component.ts
+++ b/src/app/components/section-canvas/section-canvas.component.ts
@@ -1,27 +1,30 @@
-import { Component, ViewChild } from "@angular/core";
+import { Component, ViewChild, Input, OnChanges, AfterViewInit, ElementRef } from "@angular/core";
 
 import {
     acSection, cSnTrapez, ParamsSectionTrapez, cSnRectang, ParamsSectionRectang, cSnCirc,
     ParamsSectionCirc, cSnPuiss, ParamsSectionPuiss, Result
 } from "jalhyd";
 
-import { CalcCanvasComponent } from "../canvas/canvas.component";
+import { ResultsComponentDirective } from "../fixedvar-results/results.component";
 
 @Component({
     selector: "section-canvas",
-    template: `<calc-canvas #calcCanvas
-    [width]="size"
-    [height]="size">
-    </calc-canvas>
-    `
+    templateUrl: "./section-canvas.component.html",
+    styleUrls: [
+        "./section-canvas.component.scss"
+    ]
 })
-export class SectionCanvasComponent {
-
-    /** default square size, supposed to match device size (computed at contruct time) */
-    public originalSize: number;
-
-    /** taille (pixels) du canvas (c'est un carré) */
-    public size = 400;
+export class SectionCanvasComponent extends ResultsComponentDirective implements AfterViewInit, OnChanges {
+
+    private static labelColors: { [key: string]: any; } = {
+        "Hs": { r: 255, g: 0, b: 0 },
+        "Hsc": { r: 0, g: 0, b: 255 },
+        "Yn": { r: 16, g: 128, b: 16 },
+        "Ycor": { r: 128, g: 128, b: 128 },
+        "Yc": { r: 255, g: 128, b: 0 },
+        "Ycon": { r: 255, g: 0, b: 255 },
+        "Y": { r: 50, g: 50, b: 50 }
+    };
 
     /** marges gauche/droite pour le texte (pixels) */
     private _textMargin = 90;
@@ -35,42 +38,59 @@ export class SectionCanvasComponent {
 
     private _section: acSection;
 
+    private _result: Result;
+
+    private _size: number;
+
     // tirants
     private _levels: Object[] = [];
 
-    @ViewChild("calcCanvas")
-    private _calcCanvas: CalcCanvasComponent;
+    public get width(): number {
+        // return this._calcCanvas.nativeElement.width;
+        return this._size;
+    }
 
+    public get height(): number {
+        // return this._calcCanvas.nativeElement.height;
+        return this._size;
+    }
+
+    private _context2d: CanvasRenderingContext2D;
+
+    @ViewChild("canvas", { static: true })
+    private _calcCanvas: ElementRef;
+
+    @Input()
     public set section(s: acSection) {
         this._section = s;
-        if (this._section) {
-            this.draw();
-        }
     }
 
-    public reset() {
-        this._section = undefined;
-        this._levels = [];
-        this._calcCanvas.clear();
+    @Input()
+    public set result(r: Result) {
+        this._result = r;
     }
 
-    private computeScale(maxWidth: number, maxHeight: number) {
-        this._scaleX = (this.size - 2 * this._textMargin) / maxWidth;
-        this._scaleY = (this.size - this._bottomMargin) / maxHeight;
+    @Input()
+    public set size(s: number) {
+        this._size = s;
+        console.log("(i) size set to", this._size);
     }
 
-    /**
-     * convertit une abscisse en m en pixels
-     */
-    private Xm2pix(x: number) {
-        return this._textMargin + x * this._scaleX;
+    // redessine le canvas chaque fois qu'une entrée change
+    public ngOnChanges() {
+        console.log("XXX section canvas on changes");
+        this.draw();
     }
 
-    /**
-     * convertit une ordonnée en m en pixels
-     */
-    private Ym2pix(y: number) {
-        return this.size - this._bottomMargin - y * this._scaleY;
+    public ngAfterViewInit() { // wait for the view to init before using the element
+        this._context2d = this._calcCanvas.nativeElement.getContext("2d");
+        console.log("<<<< after view init >>>");
+        this.draw();
+    }
+
+    public reset() {
+        this._levels = [];
+        this.clear();
     }
 
     public addLevel(val: number, label: string, rgb: {}) {
@@ -83,6 +103,45 @@ export class SectionCanvasComponent {
         return Math.max(this._section.prms.YB.v, this._levels[this._levels.length - 1]["val"]);
     }
 
+    private isSectionLevel(s: string) {
+        for (const k in SectionCanvasComponent.labelColors) {
+            if (k === s) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public draw() {
+        console.log(">> redrawing at size", this._size);
+        if (this._context2d && this._section) {
+            this.reset();
+
+            // traduction des symboles des variables calculées
+            const re = this._result.resultElement;
+            for (const k in re.values) {
+                if (k !== re.vCalcSymbol) {
+                    const lbl = k.toUpperCase();
+                    const er = re.getValue(k);
+                    // this._resultElement.addExtraResult(lbl, er);
+
+                    if (this.isSectionLevel(k)) {
+                        this.addLevel(er, k + " = " + this.formattedValue(er), SectionCanvasComponent.labelColors[k]);
+                    }
+                }
+            }
+
+            // ajout du tirant d'eau saisi
+            const valY = this._result.sourceNub.getParameter("Y").singleValue;
+            this.addLevel(valY, "Y = " + this.formattedValue(valY), SectionCanvasComponent.labelColors["Y"]);
+
+            this.sortLevels();
+            this.drawFrame();
+            const maxWidth = this.drawSection();
+            this.drawLevels(maxWidth);
+        }
+    }
+
     /**
      * dessin des pointillés au dessus de la berge
      * xmin,xmax : position gauche/droite
@@ -90,9 +149,9 @@ export class SectionCanvasComponent {
      * maxHeight : valeur maxi des cotes
      */
     private drawTopDashLines(xmin: number, xmax: number, yb: number, maxHeight: number) {
-        this._calcCanvas.setLineWidth(2);
-        this._calcCanvas.setLineDash([5]);
-        this._calcCanvas.setStrokeColor(128, 128, 128);
+        this.setLineWidth(2);
+        this.setLineDash([5]);
+        this.setStrokeColor(128, 128, 128);
         this.drawSectionLine(xmin, yb, xmin, maxHeight);
         this.drawSectionLine(xmax, yb, xmax, maxHeight);
     }
@@ -118,8 +177,8 @@ export class SectionCanvasComponent {
 
         // dessin de la section
 
-        this._calcCanvas.setStrokeColor(0, 0, 0);
-        this._calcCanvas.setLineWidth(5);
+        this.setStrokeColor(0, 0, 0);
+        this.setLineWidth(5);
         this.drawSectionLine(0, yb, lp, 0);
         this.drawSectionLine(lp, 0, lp + prms.LargeurFond.v, 0);
         this.drawSectionLine(lp + prms.LargeurFond.v, 0, maxWidth, yb);
@@ -149,8 +208,8 @@ export class SectionCanvasComponent {
 
         // dessin de la section
 
-        this._calcCanvas.setStrokeColor(0, 0, 0);
-        this._calcCanvas.setLineWidth(5);
+        this.setStrokeColor(0, 0, 0);
+        this.setLineWidth(5);
         this.drawSectionLine(0, yb, 0, 0);
         this.drawSectionLine(0, 0, prms.LargeurBerge.v, 0);
         this.drawSectionLine(prms.LargeurBerge.v, 0, maxWidth, yb);
@@ -191,8 +250,8 @@ export class SectionCanvasComponent {
 
             // dessin de la section
 
-            this._calcCanvas.setStrokeColor(0, 0, 0);
-            this._calcCanvas.setLineWidth(5);
+            this.setStrokeColor(0, 0, 0);
+            this.setLineWidth(5);
 
             const wx: number = maxWidth / 2;
             const alpha: Result = sect.CalcSection("Alpha", yb);
@@ -237,19 +296,19 @@ export class SectionCanvasComponent {
 
         // contour de la section
 
-        this._calcCanvas.setStrokeColor(0, 0, 0);
-        this._calcCanvas.setLineWidth(5);
+        this.setStrokeColor(0, 0, 0);
+        this.setLineWidth(5);
         const k: number = prms.k.v;
         const lambda: number = B / Math.pow(yb, k);
         const inv_k: number = 1 / k;
 
         const n = 20;
-        this.beginPath();
+        this._context2d.beginPath();
         for (let x: number = -B / 2; x <= B / 2; x += B / n) {
             const y: number = Math.pow(Math.abs(x) * 2 / lambda, inv_k);
-            this.lineTo(x + B / 2, y);
+            this._context2d.lineTo(this.Xm2pix(x + B / 2), this.Ym2pix(y));
         }
-        this.closePath();
+        this._context2d.stroke();
 
         // pointillés du haut
         this.drawTopDashLines(0, maxWidth, yb, maxHeight);
@@ -257,28 +316,16 @@ export class SectionCanvasComponent {
         return maxWidth;
     }
 
-    private beginPath() {
-        this._calcCanvas.context2d.beginPath();
-    }
-
-    private lineTo(x: number, y: number) {
-        this._calcCanvas.context2d.lineTo(this.Xm2pix(x), this.Ym2pix(y));
-    }
-
-    private closePath() {
-        this._calcCanvas.context2d.stroke();
-    }
-
     private drawSectionEllipse(x: number, y: number, rX: number, rY: number, rot: number, start: number, end: number) {
-        this._calcCanvas.drawEllipse(this.Xm2pix(x), this.Ym2pix(y), rX * this._scaleX, rY * this._scaleY, rot, start, end);
+        this.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) {
-        this._calcCanvas.fillText(s, this.Xm2pix(x), this.Ym2pix(y), align);
+        this.fillText(s, this.Xm2pix(x), this.Ym2pix(y), align);
     }
 
     private drawSectionLine(x1: number, y1: number, x2: number, y2: number) {
-        this._calcCanvas.drawLine(this.Xm2pix(x1), this.Ym2pix(y1), this.Xm2pix(x2), this.Ym2pix(y2));
+        this.drawLine(this.Xm2pix(x1), this.Ym2pix(y1), this.Xm2pix(x2), this.Ym2pix(y2));
     }
 
     /**
@@ -301,6 +348,25 @@ export class SectionCanvasComponent {
         throw new Error("SectionCanvasComponent.drawSection() : type de section non pris en charge");
     }
 
+    private computeScale(maxWidth: number, maxHeight: number) {
+        this._scaleX = (this._size - 2 * this._textMargin) / maxWidth;
+        this._scaleY = (this._size - this._bottomMargin) / maxHeight;
+    }
+
+    /**
+     * convertit une abscisse en m en pixels
+     */
+    private Xm2pix(x: number) {
+        return this._textMargin + x * this._scaleX;
+    }
+
+    /**
+     * convertit une ordonnée en m en pixels
+     */
+    private Ym2pix(y: number) {
+        return this._size - this._bottomMargin - y * this._scaleY;
+    }
+
     private sortLevels() {
         this._levels.sort((a, b) => {
             if (a["val"] < b["val"]) {
@@ -316,16 +382,16 @@ export class SectionCanvasComponent {
     private drawLevels(maxWidth: number) {
         let left = true;
 
-        this._calcCanvas.resetLineDash();
-        this._calcCanvas.setLineWidth(1);
-        this._calcCanvas.setFont("12px sans- serif");
+        this.resetLineDash();
+        this.setLineWidth(1);
+        this.setFont("12px sans- serif");
         for (const l of this._levels) {
             const y = l["val"];
             const col = l["rgb"];
-            this._calcCanvas.setStrokeColor(col["r"], col["g"], col["b"]);
+            this.setStrokeColor(col["r"], col["g"], col["b"]);
             this.drawSectionLine(0, y, maxWidth, y);
 
-            this._calcCanvas.setFillColor(col["r"], col["g"], col["b"]);
+            this.setFillColor(col["r"], col["g"], col["b"]);
             if (left) {
                 this.drawText(l["label"], -0.1, y, "right");
             } else {
@@ -337,17 +403,75 @@ export class SectionCanvasComponent {
 
     // contour du canvas
     private drawFrame() {
-        this._calcCanvas.clear();
-        this._calcCanvas.resetLineDash();
-        this._calcCanvas.setStrokeColor(128, 128, 128);
-        this._calcCanvas.drawRect(0, 0, this._calcCanvas.width, this._calcCanvas.height);
+        this.clear();
+        this.resetLineDash();
+        this.setStrokeColor(128, 128, 128);
+        this.drawRect(0, 0, this.width, this.height);
     }
 
-    public draw() {
-        // console.log(">> redrawing at size", this.size);
-        this.sortLevels();
-        this.drawFrame();
-        const maxWidth = this.drawSection();
-        this.drawLevels(maxWidth);
+    public clear() {
+        if (this._context2d) {
+            this._context2d.clearRect(0, 0, this.width, this.height);
+        }
+    }
+
+    public setStrokeColor(r: number, g: number, b: number) {
+        const col: string = "rgb(" + r + "," + g + "," + b + ")";
+        this._context2d.strokeStyle = col;
+    }
+
+    public setFillColor(r: number, g: number, b: number) {
+        const col: string = "rgb(" + r + "," + g + "," + b + ")";
+        this._context2d.fillStyle = col;
+    }
+
+    public setFont(f: string) {
+        this._context2d.font = f;
+    }
+
+    public fillText(s: string, x: number, y: number, align?: any) {
+        if (align) {
+            this._context2d.textAlign = align;
+        }
+        this._context2d.fillText(s, x, y);
+    }
+
+    public setLineWidth(w: number) {
+        this._context2d.lineWidth = w;
+    }
+
+    public setLineDash(d: number[]) {
+        this._context2d.setLineDash(d);
+    }
+
+    public resetLineDash() {
+        this._context2d.setLineDash([]);
+    }
+
+    public drawRect(x1: number, y1: number, w: number, h: number) {
+        this._context2d.strokeRect(x1, y1, w, h);
+    }
+
+    public drawLine(x1: number, y1: number, x2: number, y2: number) {
+        this._context2d.beginPath();
+        this._context2d.moveTo(x1, y1);
+        this._context2d.lineTo(x2, y2);
+        this._context2d.stroke();
+    }
+
+    /**
+     *
+     * @param x The x axis of the coordinate for the ellipse's center.
+     * @param y The y axis of the coordinate for the ellipse's center.
+     * @param radiusX The ellipse's major-axis radius.
+     * @param radiusY The ellipse's minor-axis radius.
+     * @param rotation The rotation for this ellipse, expressed in radians
+     * @param startAngle The starting point, measured from the x axis, from which it will be drawn, expressed in radians
+     * @param endAngle The end ellipse's angle to which it will be drawn, expressed in radians
+     */
+    public drawEllipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number) {
+        this._context2d.beginPath();
+        this._context2d.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle);
+        this._context2d.stroke();
     }
 }
diff --git a/src/app/components/section-results/section-results.component.html b/src/app/components/section-results/section-results.component.html
index ff26a315c..9f855a34e 100644
--- a/src/app/components/section-results/section-results.component.html
+++ b/src/app/components/section-results/section-results.component.html
@@ -17,7 +17,7 @@
 
         <!-- graphique -->
         <div class="canvas-container">
-            <section-canvas></section-canvas>
+            <section-canvas [result]=result [section]=section [size]=size></section-canvas>
         </div>
     </div>
 </div>
diff --git a/src/app/components/section-results/section-results.component.ts b/src/app/components/section-results/section-results.component.ts
index 8590e0248..359845b85 100644
--- a/src/app/components/section-results/section-results.component.ts
+++ b/src/app/components/section-results/section-results.component.ts
@@ -1,8 +1,5 @@
-import { Component, ViewChild, ElementRef, Input } from "@angular/core";
+import { Component, ElementRef, Input, AfterContentChecked } from "@angular/core";
 
-import { ResultElement } from "jalhyd";
-
-import { SectionCanvasComponent } from "../section-canvas/section-canvas.component";
 import { SectionResults } from "../../results/section-results";
 import { CalculatorResults } from "../../results/calculator-results";
 import { I18nService } from "../../services/internationalisation.service";
@@ -18,17 +15,30 @@ import { FixedVarResultsComponent } from "../fixedvar-results/fixedvar-results.c
 })
 export class SectionResultsComponent extends ResultsComponentDirective {
 
+    /** taille (pixels) du canvas (c'est un carré) */
+    public _size: number;
+
+    /** hardcoded bullet-proof default canvas size **/
+    private previousContainerSize: number;
+
+    private defaultSize = 400;
+
+    private minimalSize = 300;
+
+    /**  résultats non mis en forme */
+    private _results: SectionResults;
+
     constructor(
         private intlService: I18nService,
         private element: ElementRef,
     ) {
         super();
+        this.previousContainerSize = this.defaultSize;
+        this._size = this.previousContainerSize;
     }
 
     @Input()
     public set results(rs: CalculatorResults[]) {
-        super.results = rs;
-        this._resultElement = undefined;
         this._results = undefined;
         if (rs) {
             for (const r of rs) {
@@ -37,96 +47,22 @@ export class SectionResultsComponent extends ResultsComponentDirective {
                 }
             }
         }
-        this.drawSectionCanvas();
     }
 
-    /** détermine s'il y a des résultats de section "fixes" (pas de paramètre varié, graphique de la section) */
     public get hasResults(): boolean {
         return this._results && this._results.hasResults;
     }
 
-    public get resultElement() {
-        return this._resultElement;
+    public get section() {
+        return this._results.section;
     }
 
-    private static labelColors: { [key: string]: any; } = {
-        "Hs": { r: 255, g: 0, b: 0 },
-        "Hsc": { r: 0, g: 0, b: 255 },
-        "Yn": { r: 16, g: 128, b: 16 },
-        "Ycor": { r: 128, g: 128, b: 128 },
-        "Yc": { r: 255, g: 128, b: 0 },
-        "Ycon": { r: 255, g: 0, b: 255 },
-        "Y": { r: 50, g: 50, b: 50 }
-    };
-
-    /** hardcoded bullet-proof default canvas size **/
-    private previousContainerSize = 400;
-
-    /**  résultats non mis en forme */
-    private _results: SectionResults;
-
-    /**
-     * ResultElement mis en forme (symboles des variables traduits)
-     */
-    private _resultElement: ResultElement;
-
-    @ViewChild(SectionCanvasComponent)
-    private _sectionCanvasComponent: SectionCanvasComponent;
-
-    private isSectionLevel(s: string) {
-        for (const k in SectionResultsComponent.labelColors) {
-            if (k === s) {
-                return true;
-            }
-        }
-        return false;
+    public get result() {
+        return this._results.result;
     }
 
-    private drawSectionCanvas() {
-        if (this._results && this._sectionCanvas) {
-
-            this._sectionCanvas.reset();
-
-            this._resultElement = new ResultElement();
-
-            // compute canvas optimal size the first time
-            if (this._sectionCanvasComponent.originalSize === undefined) {
-                const container = this.element.nativeElement.querySelector(".section-results-container");
-                const size = Math.min(container.offsetWidth, container.offsetHeight);
-                this._sectionCanvasComponent.originalSize = size - 17; // 417 - 17 = 400
-                this._sectionCanvasComponent.size = this._sectionCanvasComponent.originalSize;
-            }
-
-            // traduction des symboles des variables calculées
-            const re = this._results.result.resultElement;
-            for (const k in re.values) {
-                if (k !== re.vCalcSymbol) {
-                    const lbl = k.toUpperCase();
-                    const er = re.getValue(k);
-                    this._resultElement.addExtraResult(lbl, er);
-
-                    if (this.isSectionLevel(k)) {
-                        this._sectionCanvasComponent.addLevel(
-                            er, k + " = " + this.formattedValue(er), SectionResultsComponent.labelColors[k]
-                        );
-                    }
-                }
-            }
-
-            // ajout du tirant d'eau saisi
-            const valY = this._results.result.sourceNub.getParameter("Y").singleValue;
-            this._sectionCanvasComponent.addLevel(valY, "Y = " + this.formattedValue(valY), SectionResultsComponent.labelColors["Y"]);
-
-            // wait just a little to draw, in case this._sectionCanvas.size was changed above (1st run)
-            setTimeout(() => {
-                if (this._results && this._results.section) {
-                    this._sectionCanvasComponent.section = this._results.section;
-                }
-            }, 100);
-        }
-
-        const canvasUpdated = (! this.hasResults || this._sectionCanvasComponent !== undefined);
-        return superUpdated && canvasUpdated;
+    public get size() {
+        return this._size;
     }
 
     public exportAsImage(element: HTMLDivElement) {
@@ -135,26 +71,34 @@ export class SectionResultsComponent extends ResultsComponentDirective {
 
     /** redraw canvas on fullscreen state change (scale drawing) */
     public fullscreenChange(isFullscreen: boolean) {
-        this._sectionCanvasComponent.size = this.getContainerSize(! isFullscreen);
-        this.previousContainerSize = this._sectionCanvasComponent.size;
-        setTimeout(() => {
-            this._sectionCanvasComponent.draw();
-        }, 100);
+        this._size = this.getContainerSize(! isFullscreen, isFullscreen);
+        this.previousContainerSize = this._size;
     }
 
-    private getContainerSize(useOriginalSize: boolean = false): number {
+    private getContainerSize(useDefaultSize: boolean = false, useMinOfWidthAndHeight: boolean = false): number {
         const container = this.element.nativeElement.querySelector(".section-results-container");
+        console.log("[container size in getContainerSize]", container.offsetWidth, container.offsetHeight);
         let size: number;
         if (container) {
-            size = Math.min(container.offsetWidth, container.offsetHeight);
+            if (useMinOfWidthAndHeight) {
+                // when going to fullscreen mode, ensure the drawing
+                // is not larger or higher than the screen
+                size = Math.min(container.offsetWidth, container.offsetHeight);
+            } else {
+                size = container.offsetWidth;
+            }
         } else {
             size = this.previousContainerSize;
         }
         // when going back from fullscreen mode, container size tends to be
-        // too high for whatever reason; use originalSize on this purpose
-        if (useOriginalSize) {
-            size = Math.min(size, this._sectionCanvasComponent.originalSize);
+        // too high for whatever reason; use defaultSize on this purpose
+        if (useDefaultSize) {
+            console.log("~~ use default ~~", size, this.defaultSize);
+            size = this.defaultSize;
         }
+        // lower boundary
+        size = Math.max(size, this.minimalSize);
+
         return size;
     }
 
-- 
GitLab


From 5ebaf8eafc939c254e0672a8ad354cc8db63e6f5 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Tue, 21 Jul 2020 11:39:28 +0200
Subject: [PATCH 07/12] Simplified plottable results charts in PAB and MRC

---
 .../macrorugo-compound-results.component.html |   8 +-
 .../macrorugo-compound-results.component.ts   |  17 +-
 .../pab-results/pab-results.component.html    |   8 +-
 .../pab-results/pab-results.component.ts      |  12 --
 .../pb-results/pb-results.component.html      |   4 +-
 .../results-chart/results-chart.component.ts  |   5 +
 src/app/results/macrorugo-compound-results.ts | 108 ++++++++++++-
 src/app/results/pab-results.ts                | 130 +++++++++++++++-
 .../plottable-macrorugo-compound-results.ts   | 124 ---------------
 src/app/results/plottable-pab-results.ts      | 147 ------------------
 10 files changed, 251 insertions(+), 312 deletions(-)
 delete mode 100644 src/app/results/plottable-macrorugo-compound-results.ts
 delete mode 100644 src/app/results/plottable-pab-results.ts

diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
index 9ce5cecca..593252b2c 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.html
@@ -1,11 +1,11 @@
 <div class="container">
 
-    <log #generalLog [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
+    <log [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
 
     <variable-results-selector [results]=mrcResults [variatedParameters]=mrcResults?.variatedParameters>
     </variable-results-selector>
 
-    <log #iterationLog [log]=iterationLog></log>
+    <log [log]=iterationLog></log>
 
     <div>
         <!-- tableau de résultats -->
@@ -22,8 +22,8 @@
         [align]="'left'"></quicknav>
 
     <div id="macrorugo-compound-graphs-container" class="container" fxLayout="row wrap" fxLayoutAlign="space-around start">
-        <results-chart *ngIf="hasDisplayableResults" [results]=plottableResults [resultData]=plottableResults?.result
-          fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
+        <results-chart *ngIf="hasDisplayableResults" [results]=mrcResults [resultData]=mrcResults?.result
+          [variableIndex]=mrcResults?.variableIndex fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </results-chart>
     </div>
 
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
index 6c17591e8..4e4f108bb 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
@@ -1,4 +1,4 @@
-import { Component, Input, OnChanges } from "@angular/core";
+import { Component, Input } from "@angular/core";
 
 import { Result, cLog, Message, MessageCode, MessageSeverity, MRCInclination } from "jalhyd";
 
@@ -7,10 +7,8 @@ import { fv } from "../../../app/util";
 import { CalculatorResults } from "../../results/calculator-results";
 import { NgParameter } from "../../formulaire/elements/ngparam";
 import { ApplicationSetupService } from "../../services/app-setup.service";
-import { PlottableData } from "../../results/plottable-data";
 import { I18nService } from "../../services/internationalisation.service";
 import { MacrorugoCompoundResults } from "../../results/macrorugo-compound-results";
-import { PlottableMacrorugoCompoundResults } from "../../results/plottable-macrorugo-compound-results";
 import { ResultsComponentDirective } from "../fixedvar-results/results.component";
 
 @Component({
@@ -20,7 +18,7 @@ import { ResultsComponentDirective } from "../fixedvar-results/results.component
         "./macrorugo-compound-results.component.scss"
     ]
 })
-export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective implements OnChanges {
+export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective {
 
     /** résultats non mis en forme */
     private _mrcResults: MacrorugoCompoundResults;
@@ -32,10 +30,6 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
         super();
     }
 
-    public ngOnChanges() {
-        // console.log("--------> MRCR_C changes…");
-    }
-
     @Input()
     public set results(rs: CalculatorResults[]) {
         this._mrcResults = undefined;
@@ -228,11 +222,4 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
         return fv(lincl);
     }
 
-    /** builds a set of PlottableData from MacrorugoCompoundResults, to feed the chart */
-    protected get plottableResults(): PlottableData {
-        const plottableResults = new PlottableMacrorugoCompoundResults();
-        plottableResults.setMrcResults(this.mrcResults);
-        return plottableResults;
-    }
-
 }
diff --git a/src/app/components/pab-results/pab-results.component.html b/src/app/components/pab-results/pab-results.component.html
index 225c00f9e..a85d72bd6 100644
--- a/src/app/components/pab-results/pab-results.component.html
+++ b/src/app/components/pab-results/pab-results.component.html
@@ -1,11 +1,11 @@
 <div class="container">
 
-    <log #generalLog [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
+    <log [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
 
     <variable-results-selector [results]="pabResults" [variatedParameters]=pabResults?.variatedParameters>
     </variable-results-selector>
 
-    <log #iterationLog [log]=iterationLog></log>
+    <log [log]=iterationLog></log>
 
     <div>
         <!-- tableau de résultats -->
@@ -20,8 +20,8 @@
     <div id="pab-graphs-container" class="container" fxLayout="row wrap" fxLayoutAlign="space-around start">
         <pab-profile-chart *ngIf="hasDisplayableResults" [results]=pabResults fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </pab-profile-chart>
-        <results-chart *ngIf="hasDisplayableResults" [results]=plottableResults [resultData]=plottableResults?.result
-          fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
+        <results-chart *ngIf="hasDisplayableResults" [results]=pabResults [resultData]=pabResults?.result
+          [variableIndex]=pabResults?.variableIndex fxFlex.gt-xs="1 0 400px" fxFlex.lt-sm="1 0 300px">
         </results-chart>
     </div>
 
diff --git a/src/app/components/pab-results/pab-results.component.ts b/src/app/components/pab-results/pab-results.component.ts
index 513710980..edcbdbb30 100644
--- a/src/app/components/pab-results/pab-results.component.ts
+++ b/src/app/components/pab-results/pab-results.component.ts
@@ -4,8 +4,6 @@ import { Result, cLog, Message, MessageCode, MessageSeverity } from "jalhyd";
 
 import { CalculatorResults } from "../../results/calculator-results";
 import { PabResults } from "../../results/pab-results";
-import { PlottableData } from "../../results/plottable-data";
-import { PlottablePabResults } from "../../results/plottable-pab-results";
 import { I18nService } from "../../services/internationalisation.service";
 import { ResultsComponentDirective } from "../fixedvar-results/results.component";
 
@@ -21,14 +19,10 @@ export class PabResultsComponent extends ResultsComponentDirective {
     /** résultats non mis en forme */
     private _pabResults: PabResults;
 
-    /** résultats mis en forme pour le graphique de données (classique) */
-    private _plottableResults: PlottablePabResults;
-
     constructor(
         private i18nService: I18nService,
     ) {
         super();
-        this._plottableResults = new PlottablePabResults();
     }
 
     @Input()
@@ -226,10 +220,4 @@ export class PabResultsComponent extends ResultsComponentDirective {
         return this.i18nService.localizeText("INFO_TITREJOURNAL_GLOBAL");
     }
 
-    /** builds a set of PlottableData from PabResults, to feed the chart */
-    protected get plottableResults(): PlottableData {
-        this._plottableResults.setPabResults(this.pabResults);
-        return this._plottableResults;
-    }
-
 }
diff --git a/src/app/components/pb-results/pb-results.component.html b/src/app/components/pb-results/pb-results.component.html
index cce785e43..ae3009105 100644
--- a/src/app/components/pb-results/pb-results.component.html
+++ b/src/app/components/pb-results/pb-results.component.html
@@ -1,10 +1,10 @@
 <div class="container">
-    <log #generalLog [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
+    <log [logTitle]="uitextGeneralLogTitle" [log]=globalLog>log général</log>
 
     <variable-results-selector [results]=pbResults>
     </variable-results-selector>
 
-    <log #iterationLog [log]=iterationLog></log>
+    <log [log]=iterationLog></log>
 
     <!-- tableau de résultats des bassins -->
     <pb-results-table *ngIf="hasBasinResults" [results]=pbResults></pb-results-table>
diff --git a/src/app/components/results-chart/results-chart.component.ts b/src/app/components/results-chart/results-chart.component.ts
index 2dd547434..d8fd854ae 100644
--- a/src/app/components/results-chart/results-chart.component.ts
+++ b/src/app/components/results-chart/results-chart.component.ts
@@ -103,6 +103,11 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
         // trick to trigger onChanges when results data changes
     }
 
+    @Input()
+    public set variableIndex(v: number) {
+        // trick to trigger onChanges when variable index changes
+    }
+
     public get availableXAxis(): string[] {
         if (this._results) {
             return this._results.getAvailableXAxis();
diff --git a/src/app/results/macrorugo-compound-results.ts b/src/app/results/macrorugo-compound-results.ts
index 8aba75366..74e776f72 100644
--- a/src/app/results/macrorugo-compound-results.ts
+++ b/src/app/results/macrorugo-compound-results.ts
@@ -1,9 +1,11 @@
-import { Result } from "jalhyd";
+import { Result, ParamDefinition } from "jalhyd";
 
 import { ServiceFactory } from "../services/service-factory";
 import { MultiDimensionResults } from "./multidimension-results";
+import { PlottableData } from "./plottable-data";
+import { ChartType } from "./chart-type";
 
-export class MacrorugoCompoundResults extends MultiDimensionResults {
+export class MacrorugoCompoundResults extends MultiDimensionResults implements PlottableData {
 
     /** résultats des modules MacroRugo enfants */
     public childrenResults: Result[];
@@ -11,6 +13,10 @@ export class MacrorugoCompoundResults extends MultiDimensionResults {
     /** symboles des colonnes de résultat */
     protected _columns: string[];
 
+    public chartType: ChartType = ChartType.Scatter;
+    public chartX: string;
+    public chartY: string;
+
     public constructor() {
         super();
         this.reset();
@@ -28,6 +34,9 @@ export class MacrorugoCompoundResults extends MultiDimensionResults {
             "ENUM_MacroRugoFlowType",
             "xCenter"
         ];
+        // axes par défaut
+        this.chartX = this.chartX || "xCenter";
+        this.chartY = this.chartY || "Q";
     }
 
     /** headers symbols */
@@ -119,4 +128,99 @@ export class MacrorugoCompoundResults extends MultiDimensionResults {
 
         return err;
     }
+    public hasPlottableResults(): boolean {
+        return this.hasResults;
+    }
+
+    /**
+     * Returns the label to display, for an element of getAvailableChartAxis()
+     * @param symbol parameter / result symbol (ex: "Q")
+     */
+    public getChartAxisLabel(symbol: string): string {
+        return this.headers[this.columns.indexOf(symbol)];
+    }
+
+    public expandLabelFromSymbol(p: ParamDefinition): string {
+        return p.symbol;
+    }
+
+    /**
+     * Returns a list of plottable parameters / result elements, that can be defined
+     * as X or Y chart axis
+     */
+    public getAvailableChartAxis(): string[] {
+        const axis = [];
+        for (const c of this.columns) {
+            if (c.indexOf("ENUM_") === -1) { // ENUM variables are not plottable
+                axis.push(c);
+            }
+        }
+        return axis;
+    }
+
+    public getAvailableXAxis(): string[] {
+        return this.getAvailableChartAxis();
+    }
+
+    public getAvailableYAxis(): string[] {
+        return this.getAvailableChartAxis();
+    }
+
+    // just to implement interface
+    public getVariatingParametersSymbols(): string[] {
+        return [];
+    }
+
+    /**
+     * Returns the series of values for the required symbol
+     * @param symbol parameter / result symbol (ex: "Q")
+     */
+    public getValuesSeries(symbol: string): number[] {
+        const data: number[] = [];
+        const l = this.childrenResults.length;
+        // when a parameter is variating, index of the variating parameter
+        // values to build the data from
+        const vi = this.variableIndex;
+
+        if (this.iterationHasError(vi)) {
+            return [];
+        }
+
+        for (let i = 0; i < l; i++) {
+            switch (symbol) {
+                case "RADIER_N":
+                    data.push(i + 1);
+                    break;
+
+                case "ZF1":
+                case "Y":
+                case "B":
+                    let v: number;
+                    const nub = this.childrenResults[i].sourceNub;
+                    const param = nub.getParameter(symbol);
+                    try {
+                        if (param.hasMultipleValues) {
+                            v = param.getInferredValuesList()[vi];
+                        } else {
+                            v = param.singleValue;
+                        }
+                    } catch (e) {
+                        // silent fail
+                    }
+                    data.push(v);
+                    break;
+
+                case "Q":
+                case "Vdeb":
+                case "Fr":
+                case "Vmax":
+                case "PV":
+                case "xCenter":
+                    data.push(this.childrenResults[i].resultElements[vi].getValue(symbol));
+                    break;
+            }
+        }
+
+        return data;
+    }
 }
diff --git a/src/app/results/pab-results.ts b/src/app/results/pab-results.ts
index d08b381f1..f77a2f9b4 100644
--- a/src/app/results/pab-results.ts
+++ b/src/app/results/pab-results.ts
@@ -1,9 +1,11 @@
-import { Result } from "jalhyd";
+import { Result, ParamDefinition } from "jalhyd";
 
 import { ServiceFactory } from "../services/service-factory";
 import { MultiDimensionResults } from "./multidimension-results";
+import { PlottableData } from "./plottable-data";
+import { ChartType } from "./chart-type";
 
-export class PabResults extends MultiDimensionResults {
+export class PabResults extends MultiDimensionResults implements PlottableData {
 
     /** résultats des modules Cloisons avant chaque bassin */
     public cloisonsResults: Result[];
@@ -20,6 +22,10 @@ export class PabResults extends MultiDimensionResults {
     /** symboles des colonnes de résultat */
     protected _columns: string[];
 
+    public chartType: ChartType = ChartType.Scatter;
+    public chartX: string;
+    public chartY: string;
+
     public constructor() {
         super();
         this.reset();
@@ -36,6 +42,9 @@ export class PabResults extends MultiDimensionResults {
             "QA",
             "ENUM_StructureJetType"
         ];
+        // axes par défaut
+        this.chartX = this.chartX || "CLOISON";
+        this.chartY = this.chartY || "YMOY";
     }
 
     /** headers symbols */
@@ -130,4 +139,121 @@ export class PabResults extends MultiDimensionResults {
 
         return err;
     }
+
+    public hasPlottableResults(): boolean {
+        return this.hasResults;
+    }
+
+    /**
+     * Returns the label to display, for an element of getAvailableChartAxis()
+     * @param symbol parameter / result symbol (ex: "Q")
+     */
+    public getChartAxisLabel(symbol: string): string {
+        if (symbol === "x") { // specific case for wall abscissa
+            return ServiceFactory.instance.i18nService.localizeText("INFO_LIB_ABSCISSE_CLOISON");
+        } else {
+            return this.headers[this.columns.indexOf(symbol)];
+        }
+    }
+
+    public expandLabelFromSymbol(p: ParamDefinition): string {
+        return p.symbol;
+    }
+
+    /**
+     * Returns a list of plottable parameters / result elements, that can be defined
+     * as X or Y chart axis
+     */
+    public getAvailableChartAxis(): string[] {
+        const axis = [];
+        axis.push("x"); // wall abscissa
+        for (const c of this.columns) {
+            if (c.indexOf("ENUM_") === -1) { // ENUM variables are not plottable
+                axis.push(c);
+            }
+        }
+        return axis;
+    }
+
+    public getAvailableXAxis(): string[] {
+        return this.getAvailableChartAxis();
+    }
+
+    public getAvailableYAxis(): string[] {
+        return this.getAvailableChartAxis();
+    }
+
+    // just to implement interface
+    public getVariatingParametersSymbols(): string[] {
+        return [];
+    }
+
+    /**
+     * Returns the series of values for the required symbol
+     * @param symbol parameter / result symbol (ex: "Q")
+     */
+    public getValuesSeries(symbol: string): number[] {
+        const data: number[] = [];
+        const l = this.cloisonsResults.length;
+        // when a parameter is variating, index of the variating parameter
+        // values to build the data from
+        const vi = this.variableIndex;
+
+        if (this.iterationHasError(vi)) {
+            return [];
+        }
+
+        switch (symbol) {
+            case "CLOISON":
+                data.push(undefined);
+                for (let i = 0; i <= l; i++) { // <= for one extra step (downwall)
+                    data.push(i + 1);
+                }
+                break;
+
+            case "DH":
+            case "ZRAM":
+            case "Q":
+                data.push(undefined);
+                for (let i = 0; i < l; i++) {
+                    const er = this.cloisonsResults[i].resultElements[vi].getValue(symbol);
+                    data.push(er);
+                }
+                const zrAval = this.cloisonAvalResults.resultElements[vi].getValue(symbol);
+                data.push(zrAval);
+                break;
+
+            case "Z":
+                for (let i = 0; i < l; i++) {
+                    data.push(this.cloisonsResults[i].resultElements[vi].vCalc);
+                }
+                data.push(this.cloisonAvalResults.resultElements[vi].vCalc);
+                data.push(this.Z2[vi]);
+                break;
+
+            case "PV":
+            case "YMOY":
+            case "ZRMB":
+            case "QA":
+                data.push(undefined);
+                for (let i = 0; i < l; i++) {
+                    const er = this.cloisonsResults[i].resultElements[vi].getValue(symbol);
+                    data.push(er);
+                }
+                data.push(undefined);
+                break;
+
+            case "x": // wall abscissa
+                data.push(undefined);
+                for (let i = 0; i < l; i++) {
+                    const er = this.cloisonsResults[i].resultElements[vi].getValue(symbol);
+                    data.push(er);
+                }
+                const erXdw = this.cloisonAvalResults.resultElements[vi].getValue(symbol);
+                data.push(erXdw);
+                break;
+        }
+
+        return data;
+    }
 }
diff --git a/src/app/results/plottable-macrorugo-compound-results.ts b/src/app/results/plottable-macrorugo-compound-results.ts
deleted file mode 100644
index ace4357c6..000000000
--- a/src/app/results/plottable-macrorugo-compound-results.ts
+++ /dev/null
@@ -1,124 +0,0 @@
-import { PlottableData } from "./plottable-data";
-import { ChartType } from "./chart-type";
-import { MacrorugoCompoundResults } from "./macrorugo-compound-results";
-
-import { ParamDefinition } from "jalhyd";
-
-export class PlottableMacrorugoCompoundResults implements PlottableData {
-
-    public chartType: ChartType = ChartType.Scatter;
-    public chartX: string;
-    public chartY: string;
-
-    protected mrcResults: MacrorugoCompoundResults;
-
-    public constructor(mrcResults?: MacrorugoCompoundResults) {
-        if (mrcResults) {
-            this.setMrcResults(mrcResults);
-        }
-        // axes par défaut
-        this.chartX = this.chartX || "xCenter";
-        this.chartY = this.chartY || "Q";
-    }
-
-    public hasPlottableResults(): boolean {
-        return this.mrcResults && this.mrcResults.hasResults;
-    }
-
-    /** reaffect mrcResults, for ex. when objet was contructed with empty mrcResults */
-    public setMrcResults(mrcResults: MacrorugoCompoundResults) {
-        this.mrcResults = mrcResults;
-    }
-
-    /**
-     * Returns the label to display, for an element of getAvailableChartAxis()
-     * @param symbol parameter / result symbol (ex: "Q")
-     */
-    public getChartAxisLabel(symbol: string): string {
-        return this.mrcResults.headers[this.mrcResults.columns.indexOf(symbol)];
-    }
-
-    public expandLabelFromSymbol(p: ParamDefinition): string {
-        return p.symbol;
-    }
-
-    /**
-     * Returns a list of plottable parameters / result elements, that can be defined
-     * as X or Y chart axis
-     */
-    public getAvailableChartAxis(): string[] {
-        const axis = [];
-        for (const c of this.mrcResults.columns) {
-            if (c.indexOf("ENUM_") === -1) { // ENUM variables are not plottable
-                axis.push(c);
-            }
-        }
-        return axis;
-    }
-
-    public getAvailableXAxis(): string[] {
-        return this.getAvailableChartAxis();
-    }
-
-    public getAvailableYAxis(): string[] {
-        return this.getAvailableChartAxis();
-    }
-
-    // just to implement interface
-    public getVariatingParametersSymbols(): string[] {
-        return [];
-    }
-
-    /**
-     * Returns the series of values for the required symbol
-     * @param symbol parameter / result symbol (ex: "Q")
-     */
-    public getValuesSeries(symbol: string): number[] {
-        const data: number[] = [];
-        const l = this.mrcResults.childrenResults.length;
-        // when a parameter is variating, index of the variating parameter
-        // values to build the data from
-        const vi = this.mrcResults.variableIndex;
-
-        if (this.mrcResults.iterationHasError(vi)) {
-            return [];
-        }
-
-        for (let i = 0; i < l; i++) {
-            switch (symbol) {
-                case "RADIER_N":
-                    data.push(i + 1);
-                    break;
-
-                case "ZF1":
-                case "Y":
-                case "B":
-                    let v: number;
-                    const nub = this.mrcResults.childrenResults[i].sourceNub;
-                    const param = nub.getParameter(symbol);
-                    try {
-                        if (param.hasMultipleValues) {
-                            v = param.getInferredValuesList()[vi];
-                        } else {
-                            v = param.singleValue;
-                        }
-                    } catch (e) {
-                        // silent fail
-                    }
-                    data.push(v);
-                    break;
-
-                case "Q":
-                case "Vdeb":
-                case "Fr":
-                case "Vmax":
-                case "PV":
-                case "xCenter":
-                    data.push(this.mrcResults.childrenResults[i].resultElements[vi].getValue(symbol));
-                    break;
-            }
-        }
-
-        return data;
-    }
-}
diff --git a/src/app/results/plottable-pab-results.ts b/src/app/results/plottable-pab-results.ts
deleted file mode 100644
index ad75a959e..000000000
--- a/src/app/results/plottable-pab-results.ts
+++ /dev/null
@@ -1,147 +0,0 @@
-import { PlottableData } from "./plottable-data";
-import { PabResults } from "./pab-results";
-import { ChartType } from "./chart-type";
-import { ServiceFactory } from "../services/service-factory";
-
-import { ParamDefinition } from "jalhyd";
-
-export class PlottablePabResults implements PlottableData {
-
-    public chartType: ChartType = ChartType.Scatter;
-    public chartX: string;
-    public chartY: string;
-
-    protected pabResults: PabResults;
-
-    public constructor(pabResults?: PabResults) {
-        if (pabResults) {
-            this.setPabResults(pabResults);
-        }
-        // axes par défaut
-        this.chartX = this.chartX || "CLOISON";
-        this.chartY = this.chartY || "YMOY";
-    }
-
-    public hasPlottableResults(): boolean {
-        return this.pabResults && this.pabResults.hasResults;
-    }
-
-    /** reaffect pabResults, for ex. when objet was contructed with empty pabResults */
-    public setPabResults(pabResults: PabResults) {
-        this.pabResults = pabResults;
-    }
-
-    /**
-     * Returns the label to display, for an element of getAvailableChartAxis()
-     * @param symbol parameter / result symbol (ex: "Q")
-     */
-    public getChartAxisLabel(symbol: string): string {
-        if (symbol === "x") { // specific case for wall abscissa
-            return ServiceFactory.i18nService.localizeText("INFO_LIB_ABSCISSE_CLOISON");
-        } else {
-            return this.pabResults.headers[this.pabResults.columns.indexOf(symbol)];
-        }
-    }
-
-    public expandLabelFromSymbol(p: ParamDefinition): string {
-        return p.symbol;
-    }
-
-    /**
-     * Returns a list of plottable parameters / result elements, that can be defined
-     * as X or Y chart axis
-     */
-    public getAvailableChartAxis(): string[] {
-        const axis = [];
-        axis.push("x"); // wall abscissa
-        for (const c of this.pabResults.columns) {
-            if (c.indexOf("ENUM_") === -1) { // ENUM variables are not plottable
-                axis.push(c);
-            }
-        }
-        return axis;
-    }
-
-    public getAvailableXAxis(): string[] {
-        return this.getAvailableChartAxis();
-    }
-
-    public getAvailableYAxis(): string[] {
-        return this.getAvailableChartAxis();
-    }
-
-    // just to implement interface
-    public getVariatingParametersSymbols(): string[] {
-        return [];
-    }
-
-    /**
-     * Returns the series of values for the required symbol
-     * @param symbol parameter / result symbol (ex: "Q")
-     */
-    public getValuesSeries(symbol: string): number[] {
-        const data: number[] = [];
-        const pr = this.pabResults;
-        const l = this.pabResults.cloisonsResults.length;
-        // when a parameter is variating, index of the variating parameter
-        // values to build the data from
-        const vi = this.pabResults.variableIndex;
-
-        if (this.pabResults.iterationHasError(vi)) {
-            return [];
-        }
-
-        switch (symbol) {
-            case "CLOISON":
-                data.push(undefined);
-                for (let i = 0; i <= l; i++) { // <= for one extra step (downwall)
-                    data.push(i + 1);
-                }
-                break;
-
-            case "DH":
-            case "ZRAM":
-            case "Q":
-                data.push(undefined);
-                for (let i = 0; i < l; i++) {
-                    const er = pr.cloisonsResults[i].resultElements[vi].getValue(symbol);
-                    data.push(er);
-                }
-                const zrAval = pr.cloisonAvalResults.resultElements[vi].getValue(symbol);
-                data.push(zrAval);
-                break;
-
-            case "Z":
-                for (let i = 0; i < l; i++) {
-                    data.push(pr.cloisonsResults[i].resultElements[vi].vCalc);
-                }
-                data.push(pr.cloisonAvalResults.resultElements[vi].vCalc);
-                data.push(pr.Z2[vi]);
-                break;
-
-            case "PV":
-            case "YMOY":
-            case "ZRMB":
-            case "QA":
-                data.push(undefined);
-                for (let i = 0; i < l; i++) {
-                    const er = pr.cloisonsResults[i].resultElements[vi].getValue(symbol);
-                    data.push(er);
-                }
-                data.push(undefined);
-                break;
-
-            case "x": // wall abscissa
-                data.push(undefined);
-                for (let i = 0; i < l; i++) {
-                    const er = pr.cloisonsResults[i].resultElements[vi].getValue(symbol);
-                    data.push(er);
-                }
-                const erXdw = pr.cloisonAvalResults.resultElements[vi].getValue(symbol);
-                data.push(erXdw);
-                break;
-        }
-
-        return data;
-    }
-}
-- 
GitLab


From 6af9d3088433cd4a9835a7f566d848f80c7ab6c6 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Tue, 21 Jul 2020 12:03:51 +0200
Subject: [PATCH 08/12] Added conditions on sub calc-results components

---
 .../calculator-results.component.html         | 10 ++--
 .../calculator-results.component.ts           | 22 ++++++++-
 .../calculator.component.ts                   | 10 ++++
 .../macrorugo-compound-results.component.ts   |  6 +--
 .../pab-results/pab-results.component.ts      |  8 ++--
 .../pb-results/pb-results.component.ts        | 46 +++++++++++++++++++
 .../remous-results.component.ts               |  1 -
 .../results-chart/results-chart.component.ts  |  2 -
 .../variable-results-selector.component.ts    |  1 -
 9 files changed, 88 insertions(+), 18 deletions(-)

diff --git a/src/app/components/calculator-results/calculator-results.component.html b/src/app/components/calculator-results/calculator-results.component.html
index 7f8019197..f057d40a4 100644
--- a/src/app/components/calculator-results/calculator-results.component.html
+++ b/src/app/components/calculator-results/calculator-results.component.html
@@ -1,10 +1,10 @@
 <div>
-    <section-results [hidden]="! isSP" [results]=formResultsArray></section-results>
-    <remous-results [hidden]="! isRemous" [results]=formResultsArray></remous-results>
-    <pab-results [hidden]="! isPAB" [results]=formResultsArray></pab-results>
-    <pb-results [hidden]="! isPB" [results]=formResultsArray></pb-results>
+    <section-results *ngIf="isSP" [results]=formResultsArray></section-results>
+    <remous-results *ngIf="isRemous" [results]=formResultsArray></remous-results>
+    <pab-results *ngIf="isPAB" [results]=formResultsArray></pab-results>
+    <pb-results *ngIf="isPB" [results]=formResultsArray></pb-results>
     <verificateur-results [hidden]="! isVerificateur"></verificateur-results>
-    <macrorugo-compound-results [hidden]="! isMRC" [results]=formResultsArray></macrorugo-compound-results>
+    <macrorugo-compound-results *ngIf="isMRC" [results]=formResultsArray></macrorugo-compound-results>
     <jet-results *ngIf="isJet" [results]=formResultsArray></jet-results>
     <fixedvar-results *ngIf="! isJet" [results]=formResultsArray></fixedvar-results>
 </div>
diff --git a/src/app/components/calculator-results/calculator-results.component.ts b/src/app/components/calculator-results/calculator-results.component.ts
index 8d6de93b5..41a6e20d1 100644
--- a/src/app/components/calculator-results/calculator-results.component.ts
+++ b/src/app/components/calculator-results/calculator-results.component.ts
@@ -37,8 +37,26 @@ export class CalculatorResultsComponent implements AfterViewChecked {
         this.afterViewChecked.emit();
     }
 
-    // JetResultsComponent extends FixedVarResultsComponent, which makes
-    // them incompatible with each other
+    public get isSP() {
+        return this.calculatorComponent.isSP;
+    }
+
+    public get isRemous() {
+        return this.calculatorComponent.isRemous;
+    }
+
+    public get isPAB() {
+        return this.calculatorComponent.isPAB;
+    }
+
+    public get isPB() {
+        return this.calculatorComponent.isPB;
+    }
+
+    public get isMRC() {
+        return this.calculatorComponent.isMRC;
+    }
+
     public get isJet() {
         return this.calculatorComponent.isJet;
     }
diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts
index 2be2d3286..4426cff87 100644
--- a/src/app/components/generic-calculator/calculator.component.ts
+++ b/src/app/components/generic-calculator/calculator.component.ts
@@ -650,6 +650,16 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
         return this.is(CalculatorType.Espece);
     }
 
+    // true if current Nub is PAR
+    public get isSP() {
+        return this.is(CalculatorType.SectionParametree);
+    }
+
+    // true if current Nub is PAR
+    public get isRemous() {
+        return this.is(CalculatorType.CourbeRemous);
+    }
+
     /**
      * Returns true if no parameter is varying; ignores parameters having
      * one of the given {except} symbols, if any
diff --git a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
index 4e4f108bb..232f0c436 100644
--- a/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
+++ b/src/app/components/macrorugo-compound-results/macrorugo-compound-results.component.ts
@@ -133,9 +133,9 @@ export class MacrorugoCompoundResultsComponent extends ResultsComponentDirective
     }
 
     /**
-     * Retourne les logs à afficher dans le composant de log global, au dessus
-     * du sélecteur d'itération : messages globaux et / ou résumé des messages
-     * spécifiques à chaque ResultElement
+     * Retourne les logs à afficher dans le composant de log local, en dessous
+     * du sélecteur d'itération : messages concernant l'itération (le ResultElement)
+     * en cours
      */
     public get iterationLog(): cLog {
         const l = new cLog();
diff --git a/src/app/components/pab-results/pab-results.component.ts b/src/app/components/pab-results/pab-results.component.ts
index edcbdbb30..bb190be6a 100644
--- a/src/app/components/pab-results/pab-results.component.ts
+++ b/src/app/components/pab-results/pab-results.component.ts
@@ -148,11 +148,11 @@ export class PabResultsComponent extends ResultsComponentDirective {
     }
 
     /**
-     * Retourne les logs à afficher dans le composant de log global, au dessus
-     * du sélecteur d'itération : messages globaux et / ou résumé des messages
-     * spécifiques à chaque ResultElement
+     * Retourne les logs à afficher dans le composant de log local, en dessous
+     * du sélecteur d'itération : messages concernant l'itération (le ResultElement)
+     * en cours
      */
-    private get iterationLog(): cLog {
+    public get iterationLog(): cLog {
         const l = new cLog();
         if (this._pabResults) {
             if (this.pabResults.variatedParameters.length > 0) {
diff --git a/src/app/components/pb-results/pb-results.component.ts b/src/app/components/pb-results/pb-results.component.ts
index 034f24e0c..b502c4e40 100644
--- a/src/app/components/pb-results/pb-results.component.ts
+++ b/src/app/components/pb-results/pb-results.component.ts
@@ -165,6 +165,52 @@ export class PbResultsComponent {
         return l;
     }
 
+    /**
+     * Retourne les logs à afficher dans le composant de log local, en dessous
+     * du sélecteur d'itération : messages concernant l'itération (le ResultElement)
+     * en cours
+     */
+    public get iterationLog(): cLog {
+        const l = new cLog();
+        /* if (this._pabResults) {
+            if (this.pabResults.variatedParameters.length > 0) {
+                // A. si un paramètre varie
+                const vi = this._pabResults.variableIndex;
+                // log de la PAB pour l'itération en cours
+                if (
+                    this._pabResults.result
+                    && this._pabResults.result.hasResultElements()
+                    && this._pabResults.result.resultElements[vi]
+                    && this._pabResults.result.resultElements[vi].hasLog()
+                ) {
+                    l.addLog(this._pabResults.result.resultElements[vi].log);
+                }
+                // logs des enfants pour l'itération en cours
+                for (const cr of this._pabResults.cloisonsResults) {
+                    if (cr && cr.hasResultElements() && cr.resultElements[vi].hasLog()) {
+                        l.addLog(cr.resultElements[vi].log);
+                    }
+                }
+                if (this._pabResults.cloisonAvalResults && this._pabResults.cloisonAvalResults.resultElements[vi].hasLog()) {
+                    l.addLog(this._pabResults.cloisonAvalResults.resultElements[vi].log);
+                }
+            } else {
+                // B. si aucun paramètre ne varie
+                this.mergeGlobalLog(this._pabResults.result, l); // faut bien mettre le log global quelque part
+                // logs des enfants
+                for (const cr of this._pabResults.cloisonsResults) {
+                    if (cr && cr.hasResultElements() && cr.resultElement.hasLog()) {
+                        l.addLog(cr.resultElement.log);
+                    }
+                }
+                if (this._pabResults.cloisonAvalResults && this._pabResults.cloisonAvalResults.resultElement.hasLog()) {
+                    l.addLog(this._pabResults.cloisonAvalResults.resultElement.log);
+                }
+            }
+        } */
+        return l;
+    }
+
     public get uitextGeneralLogTitle(): string {
         return this.i18nService.localizeText("INFO_TITREJOURNAL_GLOBAL");
     }
diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts
index 532556c37..b39505299 100644
--- a/src/app/components/remous-results/remous-results.component.ts
+++ b/src/app/components/remous-results/remous-results.component.ts
@@ -237,7 +237,6 @@ export class RemousResultsComponent extends ResultsComponentDirective implements
     private generateChart() {
         // http://www.chartjs.org/docs/latest/charts/line.html
         // le dernier dataset de la liste datasets est dessiné en 1er
-        console.log("ooOOO Oui !");
         this._remousResults.update();
 
         const nub = this._remousResults.result.sourceNub as CourbeRemous;
diff --git a/src/app/components/results-chart/results-chart.component.ts b/src/app/components/results-chart/results-chart.component.ts
index d8fd854ae..d41858fe7 100644
--- a/src/app/components/results-chart/results-chart.component.ts
+++ b/src/app/components/results-chart/results-chart.component.ts
@@ -178,13 +178,11 @@ export class ResultsChartComponent extends ResultsComponentDirective implements
     }
 
     public ngOnChanges() {
-        console.log("==> ResChart onChanges");
         // redessiner le graphique chaque fois qu'une entrée change
         this.drawChart();
     }
 
     public drawChart() {
-        console.log("----> regenerate chart !!", this._results);
         if (this._results && this._results.hasPlottableResults()) {
             switch (this._graphTypeComponent.selectedValue) {
                 case ChartType.Histogram:
diff --git a/src/app/components/variable-results-selector/variable-results-selector.component.ts b/src/app/components/variable-results-selector/variable-results-selector.component.ts
index 716d7fc9e..68491335a 100644
--- a/src/app/components/variable-results-selector/variable-results-selector.component.ts
+++ b/src/app/components/variable-results-selector/variable-results-selector.component.ts
@@ -41,7 +41,6 @@ export class VariableResultsSelectorComponent implements OnChanges {
     ) { }
 
     public ngOnChanges() {
-        console.log("==//== changes !! ==//==", this.variatedParameters);
         // rebuild variable parameters values everytime somthing changes
         if (this.variatedParameters) {
             this.varValues = [];
-- 
GitLab


From 3c9d56e4a51836de3e44d5528d97557fa148f1bc Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Wed, 16 Sep 2020 10:38:32 +0200
Subject: [PATCH 09/12] Update after merge

---
 .../calculator-results.component.ts           |  4 ++
 .../calculator.component.ts                   |  6 +-
 .../section-results.component.html            | 19 ------
 .../section-results.component.ts              |  4 +-
 .../verificateur-results.component.html       |  2 +-
 .../verificateur-results.component.ts         | 64 +------------------
 src/app/results/pab-results.ts                |  2 +-
 7 files changed, 15 insertions(+), 86 deletions(-)

diff --git a/src/app/components/calculator-results/calculator-results.component.ts b/src/app/components/calculator-results/calculator-results.component.ts
index 41a6e20d1..e26bc762f 100644
--- a/src/app/components/calculator-results/calculator-results.component.ts
+++ b/src/app/components/calculator-results/calculator-results.component.ts
@@ -61,4 +61,8 @@ export class CalculatorResultsComponent implements AfterViewChecked {
         return this.calculatorComponent.isJet;
     }
 
+    public get isVerificateur() {
+        return this.calculatorComponent.isVerificateur;
+    }
+
 }
diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts
index 4426cff87..2cd8d2d6f 100644
--- a/src/app/components/generic-calculator/calculator.component.ts
+++ b/src/app/components/generic-calculator/calculator.component.ts
@@ -645,6 +645,11 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
         return this.is(CalculatorType.Par);
     }
 
+    // true if current Nub is Verificateur
+    public get isVerificateur() {
+        return this.is(CalculatorType.Verificateur);
+    }
+
     // true if current Nub is Espece
     public get isEspece() {
         return this.is(CalculatorType.Espece);
@@ -1037,7 +1042,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
                 const form = this._formulaire as FormulaireFixedVar;
                 const nub = (form.currentNub as Espece);
                 nub.loadPredefinedSpecies(result.selected);
-                console.log("================ espèce chargée, refresh tout");
                 form.refreshFieldsets();
             }
         });
diff --git a/src/app/components/section-results/section-results.component.html b/src/app/components/section-results/section-results.component.html
index 9f855a34e..ac4e78fa0 100644
--- a/src/app/components/section-results/section-results.component.html
+++ b/src/app/components/section-results/section-results.component.html
@@ -1,6 +1,5 @@
 <div class="section-results-container" #sectionResults *ngIf="hasResults" fxLayout="row wrap"
     fxLayoutAlign="center center">
-
     <div fxFlex="1 1 100%">
         <div class="section-results-buttons">
             <button mat-icon-button (click)="exportAsImage(sectionResults)" [title]="uitextExportImageTitle">
@@ -21,21 +20,3 @@
         </div>
     </div>
 </div>
-
-<div class="container">
-    <!-- journal -->
-    <log></log>
-
-    <results-chart *ngIf="showVarResults"></results-chart>
-    <!--<results-chart [hidden]="! showVarResultsChart"></results-chart>-->
-
-    <div>
-        <!-- table des résultats fixés -->
-        <fixed-results [results]=fixedResults></fixed-results>
-
-        <!-- table des résultats variés -->
-        <div *ngIf="showVarResults">
-            <var-results [results]=varResults></var-results>
-        </div>
-    </div>
-</div>
\ No newline at end of file
diff --git a/src/app/components/section-results/section-results.component.ts b/src/app/components/section-results/section-results.component.ts
index 359845b85..0893a387f 100644
--- a/src/app/components/section-results/section-results.component.ts
+++ b/src/app/components/section-results/section-results.component.ts
@@ -1,10 +1,10 @@
-import { Component, ElementRef, Input, AfterContentChecked } from "@angular/core";
+import { Component, ElementRef, Input } from "@angular/core";
 
 import { SectionResults } from "../../results/section-results";
 import { CalculatorResults } from "../../results/calculator-results";
 import { I18nService } from "../../services/internationalisation.service";
 import { AppComponent } from "../../app.component";
-import { FixedVarResultsComponent } from "../fixedvar-results/fixedvar-results.component";
+import { ResultsComponentDirective } from "../fixedvar-results/results.component";
 
 @Component({
     selector: "section-results",
diff --git a/src/app/components/verificateur-results/verificateur-results.component.html b/src/app/components/verificateur-results/verificateur-results.component.html
index 1d0f78479..f84e65938 100644
--- a/src/app/components/verificateur-results/verificateur-results.component.html
+++ b/src/app/components/verificateur-results/verificateur-results.component.html
@@ -1,7 +1,7 @@
 <div class="container">
     <log #generalLog [logTitle]="uitextGeneralLogTitle">log général</log>
 
-    <variable-results-selector [results]="verificateurResults" (indexChange)="variableIndexChanged()">
+    <variable-results-selector [results]="verificateurResults" [variatedParameters]=verificateurResults?.variatedParameters>
     </variable-results-selector>
 
     <log-drawer #iterationLog></log-drawer>
diff --git a/src/app/components/verificateur-results/verificateur-results.component.ts b/src/app/components/verificateur-results/verificateur-results.component.ts
index 1d76c0420..d0e06ee55 100644
--- a/src/app/components/verificateur-results/verificateur-results.component.ts
+++ b/src/app/components/verificateur-results/verificateur-results.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewChild, DoCheck } from "@angular/core";
+import { Component, ViewChild } from "@angular/core";
 
 import { cLog, Message } from "jalhyd";
 
@@ -17,7 +17,7 @@ import { LogDrawerComponent } from "../log-drawer/log-drawer.component";
         "./verificateur-results.component.scss"
     ]
 })
-export class VerificateurResultsComponent extends ResultsComponentDirective implements DoCheck {
+export class VerificateurResultsComponent extends ResultsComponentDirective {
 
     /** résultats non mis en forme */
     private _verificateurResults: VerificateurResults;
@@ -45,39 +45,6 @@ export class VerificateurResultsComponent extends ResultsComponentDirective impl
         if (rs.length > 0 && rs[0] instanceof VerificateurResults) {
             this._verificateurResults = rs[0] as VerificateurResults;
         }
-        this.updateView();
-    }
-
-    /**
-     * update iteration log when the variable index changed (event sent by
-     * VariableResultsSelectorComponent); variable index is already set in
-     * verificateurResults at this time
-     */
-    public variableIndexChanged() {
-        this.updateView();
-    }
-
-    public updateView() {
-        if (this.iterationLogComponent) {
-            this.iterationLogComponent.log = undefined;
-        }
-        if (this.generalLogComponent) {
-            this.generalLogComponent.log = undefined;
-        }
-        if (this.variableResultsSelectorComponent) {
-            this.variableResultsSelectorComponent.results = undefined;
-        }
-        // set _doUpdate flag so that results are rebuilt on the next Angular display cycle
-        this._doUpdate = false;
-        if (this._verificateurResults !== undefined) {
-            this._doUpdate = this._doUpdate || this._verificateurResults.hasResults || this._verificateurResults.hasLog;
-        }
-    }
-
-    public ngDoCheck() {
-        if (this._doUpdate) {
-            this._doUpdate = !this.updateResults();
-        }
     }
 
     /*
@@ -136,33 +103,6 @@ export class VerificateurResultsComponent extends ResultsComponentDirective impl
         return l;
     }
 
-    /**
-     * met à jour l'affichage des résultats
-     * @returns true si les résultats ont pu être mis à jour
-     */
-    private updateResults() {
-        let selectorUpdated: boolean;
-
-        // results or not, there might be a log
-        const logUpdated = (this.iterationLogComponent !== undefined || this.generalLogComponent !== undefined); // gne ?
-        if (logUpdated) {
-            // order of logs is important !
-            this.iterationLogComponent.log = this.iterationLog;
-            this.generalLogComponent.log = this.globalLog;
-        }
-
-        if (this.hasResults) {
-            selectorUpdated = this.variableResultsSelectorComponent !== undefined;
-            if (selectorUpdated) {
-                this.variableResultsSelectorComponent.results = this._verificateurResults;
-            }
-        } else {
-            selectorUpdated = true;
-        }
-
-        return logUpdated && selectorUpdated;
-    }
-
     public get verificateurResults() {
         return this._verificateurResults;
     }
diff --git a/src/app/results/pab-results.ts b/src/app/results/pab-results.ts
index f77a2f9b4..d282524ef 100644
--- a/src/app/results/pab-results.ts
+++ b/src/app/results/pab-results.ts
@@ -150,7 +150,7 @@ export class PabResults extends MultiDimensionResults implements PlottableData {
      */
     public getChartAxisLabel(symbol: string): string {
         if (symbol === "x") { // specific case for wall abscissa
-            return ServiceFactory.instance.i18nService.localizeText("INFO_LIB_ABSCISSE_CLOISON");
+            return ServiceFactory.i18nService.localizeText("INFO_LIB_ABSCISSE_CLOISON");
         } else {
             return this.headers[this.columns.indexOf(symbol)];
         }
-- 
GitLab


From 6957d1049e2735bc0c0dd9e54e8218782e735c9d Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Wed, 16 Sep 2020 14:24:07 +0200
Subject: [PATCH 10/12] Fix VerificateurResults

---
 .../calculator-results.component.html         |  2 +-
 .../log-drawer/log-drawer.component.html      | 12 +++----
 .../log-drawer/log-drawer.component.ts        | 33 +++++++++++++++++--
 src/app/components/log/log.component.ts       |  8 -----
 .../verificateur-results.component.html       |  4 +--
 .../verificateur-results.component.ts         | 22 +++----------
 6 files changed, 43 insertions(+), 38 deletions(-)

diff --git a/src/app/components/calculator-results/calculator-results.component.html b/src/app/components/calculator-results/calculator-results.component.html
index f057d40a4..61ddf062b 100644
--- a/src/app/components/calculator-results/calculator-results.component.html
+++ b/src/app/components/calculator-results/calculator-results.component.html
@@ -3,7 +3,7 @@
     <remous-results *ngIf="isRemous" [results]=formResultsArray></remous-results>
     <pab-results *ngIf="isPAB" [results]=formResultsArray></pab-results>
     <pb-results *ngIf="isPB" [results]=formResultsArray></pb-results>
-    <verificateur-results [hidden]="! isVerificateur"></verificateur-results>
+    <verificateur-results *ngIf="isVerificateur" [results]=formResultsArray></verificateur-results>
     <macrorugo-compound-results *ngIf="isMRC" [results]=formResultsArray></macrorugo-compound-results>
     <jet-results *ngIf="isJet" [results]=formResultsArray></jet-results>
     <fixedvar-results *ngIf="! isJet" [results]=formResultsArray></fixedvar-results>
diff --git a/src/app/components/log-drawer/log-drawer.component.html b/src/app/components/log-drawer/log-drawer.component.html
index f2139f7c2..24c2ed3a8 100644
--- a/src/app/components/log-drawer/log-drawer.component.html
+++ b/src/app/components/log-drawer/log-drawer.component.html
@@ -3,18 +3,18 @@
         <!-- titre -->
         <div class="titre">{{ uitextTitreJournal }}</div>
         <!-- entrées du journal -->
-        <div class="log-entry" *ngFor="let entry of log">
+        <div class="log-entry" *ngFor="let entry of log; let i = index; trackBy: tbIndex">
             <log-entry [_message]="entry.message"></log-entry>
             <div *ngIf="entry.subLog.messages.length" class="drawer">
                 <div class="open-drawer">
-                    <span *ngIf="! entry.isOpen">
-                        <a (click)="entry.isOpen = true;">{{ uitextShowDetails }}</a>
+                    <span *ngIf="! entryIsOpen(i)">
+                        <a (click)="setEntryOpen(i, true);">{{ uitextShowDetails }}</a>
                     </span>
-                    <span *ngIf="entry.isOpen">
-                        <a (click)="entry.isOpen = false">{{ uitextHideDetails }}</a>
+                    <span *ngIf="entryIsOpen(i)">
+                        <a (click)="setEntryOpen(i, false);">{{ uitextHideDetails }}</a>
                     </span>
                 </div>
-                <div class="drawer-contents" [hidden]="! entry.isOpen">
+                <div class="drawer-contents" [hidden]="! entryIsOpen(i)">
                     <log-entry *ngFor="let m of entry.subLog.messages" [_message]="m"></log-entry>
                 </div>
             </div>
diff --git a/src/app/components/log-drawer/log-drawer.component.ts b/src/app/components/log-drawer/log-drawer.component.ts
index 2394e46b8..bb4fcf4f3 100644
--- a/src/app/components/log-drawer/log-drawer.component.ts
+++ b/src/app/components/log-drawer/log-drawer.component.ts
@@ -15,7 +15,9 @@ import { I18nService } from "../../services/internationalisation.service";
 export class LogDrawerComponent {
 
     /** A list of log messages accompanied by a sub-log (multiple messages) */
-    public log: Array<{ message: Message, subLog: cLog }>;
+    private _log: Array<{ message: Message, subLog: cLog }>;
+
+    private entriesStates: boolean[] = [];
 
     // title to display above the log
     @Input()
@@ -24,7 +26,16 @@ export class LogDrawerComponent {
     constructor(
         private intlService: I18nService,
     ) {
-        this.log = [];
+        this._log = [];
+    }
+
+    @Input()
+    public set log(log: Array<{ message: Message, subLog: cLog }>) {
+        this._log = log;
+    }
+
+    public get log(): Array<{ message: Message, subLog: cLog }> {
+        return this._log;
     }
 
     public get uitextTitreJournal(): string {
@@ -36,7 +47,7 @@ export class LogDrawerComponent {
     }
 
     public get hasEntries(): boolean {
-        return this.log !== undefined && this.log.length !== 0;
+        return this._log !== undefined && this._log.length !== 0;
     }
 
     public get uitextShowDetails(): string {
@@ -46,4 +57,20 @@ export class LogDrawerComponent {
     public get uitextHideDetails(): string {
         return this.intlService.localizeText("INFO_LOG_HIDE_DETAILS");
     }
+
+    public entryIsOpen(i: number): boolean {
+        if (this.entriesStates[i] !== undefined) {
+            return this.entriesStates[i];
+        }
+        return false;
+    }
+
+    public setEntryOpen(i: number, open: boolean) {
+        this.entriesStates[i] = open;
+    }
+
+    /** trackBy:index simulator @see nghyd#364 */
+    public tbIndex(index: number, item: any) {
+        return index;
+    }
 }
diff --git a/src/app/components/log/log.component.ts b/src/app/components/log/log.component.ts
index 5235954b2..b3d9c2f71 100644
--- a/src/app/components/log/log.component.ts
+++ b/src/app/components/log/log.component.ts
@@ -37,14 +37,6 @@ export class LogComponent {
         return this._log?.messages?.length > 0;
     }
 
-    /* public get messages(): Message[] {
-        let m: Message[] = [];
-        if (this._log !== undefined) {
-            m = this._log.messages;
-        }
-        return m;
-    } */
-
     @Input()
     public set log(log: cLog) {
         this._log = log;
diff --git a/src/app/components/verificateur-results/verificateur-results.component.html b/src/app/components/verificateur-results/verificateur-results.component.html
index f84e65938..b343b924e 100644
--- a/src/app/components/verificateur-results/verificateur-results.component.html
+++ b/src/app/components/verificateur-results/verificateur-results.component.html
@@ -1,8 +1,8 @@
 <div class="container">
-    <log #generalLog [logTitle]="uitextGeneralLogTitle">log général</log>
+    <log [log]="globalLog" [logTitle]="uitextGeneralLogTitle">log général</log>
 
     <variable-results-selector [results]="verificateurResults" [variatedParameters]=verificateurResults?.variatedParameters>
     </variable-results-selector>
 
-    <log-drawer #iterationLog></log-drawer>
+    <log-drawer [log]="iterationLog"></log-drawer>
 </div>
diff --git a/src/app/components/verificateur-results/verificateur-results.component.ts b/src/app/components/verificateur-results/verificateur-results.component.ts
index d0e06ee55..6770b31ac 100644
--- a/src/app/components/verificateur-results/verificateur-results.component.ts
+++ b/src/app/components/verificateur-results/verificateur-results.component.ts
@@ -1,14 +1,11 @@
-import { Component, ViewChild } from "@angular/core";
+import { Component, Input } from "@angular/core";
 
 import { cLog, Message } from "jalhyd";
 
-import { LogComponent } from "../log/log.component";
 import { CalculatorResults } from "../../results/calculator-results";
-import { VariableResultsSelectorComponent } from "../variable-results-selector/variable-results-selector.component";
 import { I18nService } from "../../services/internationalisation.service";
 import { VerificateurResults } from "../../results/verificateur-results";
 import { ResultsComponentDirective } from "../fixedvar-results/results.component";
-import { LogDrawerComponent } from "../log-drawer/log-drawer.component";
 
 @Component({
     selector: "verificateur-results",
@@ -22,24 +19,13 @@ export class VerificateurResultsComponent extends ResultsComponentDirective {
     /** résultats non mis en forme */
     private _verificateurResults: VerificateurResults;
 
-    /** true si les résultats doiventt être remis à jour */
-    private _doUpdate = false;
-
-    @ViewChild(VariableResultsSelectorComponent)
-    private variableResultsSelectorComponent: VariableResultsSelectorComponent;
-
-    @ViewChild("generalLog")
-    private generalLogComponent: LogComponent;
-
-    @ViewChild("iterationLog")
-    private iterationLogComponent: LogDrawerComponent;
-
     constructor(
         private i18nService: I18nService,
     ) {
         super();
     }
 
+    @Input()
     public set results(rs: CalculatorResults[]) {
         this._verificateurResults = undefined;
         if (rs.length > 0 && rs[0] instanceof VerificateurResults) {
@@ -51,7 +37,7 @@ export class VerificateurResultsComponent extends ResultsComponentDirective {
      * Retourne les messages à afficher dans le composant de log global, au dessus
      * du sélecteur d'itération : messages globaux du Verificateur
      */
-    private get globalLog(): cLog {
+    public get globalLog(): cLog {
         const l = new cLog();
         if (this._verificateurResults && this._verificateurResults.result && this._verificateurResults.result.hasGlobalLog()) {
             l.addLog(this._verificateurResults.result.globalLog);
@@ -63,7 +49,7 @@ export class VerificateurResultsComponent extends ResultsComponentDirective {
      * Retourne les messages à afficher dans le composant de log "du bas" : logs de l'itération
      * en cours (messages non-globaux du Vérificateur et eds Espèce), que le résultat varie ou non
      */
-    private get iterationLog(): Array<{ message: Message, subLog: cLog }> {
+    public get iterationLog(): Array<{ message: Message, subLog: cLog }> {
         const l: Array<{ message: Message, subLog: cLog }> = [];
         if (this._verificateurResults) {
             // = 0 lorsque rien ne varie
-- 
GitLab


From 8a097804466e72bb6515fbceb42175f908ee881d Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Wed, 16 Sep 2020 14:53:08 +0200
Subject: [PATCH 11/12] Simplify calculator template data injection

---
 .../calculator-results.component.ts           |  4 ++--
 .../generic-calculator/calc-name.component.ts |  7 ++++++-
 .../calculator.component.html                 |  4 ++--
 .../calculator.component.ts                   | 21 ++++---------------
 4 files changed, 14 insertions(+), 22 deletions(-)

diff --git a/src/app/components/calculator-results/calculator-results.component.ts b/src/app/components/calculator-results/calculator-results.component.ts
index e26bc762f..796d0e481 100644
--- a/src/app/components/calculator-results/calculator-results.component.ts
+++ b/src/app/components/calculator-results/calculator-results.component.ts
@@ -1,4 +1,4 @@
-import { Component, Output, EventEmitter, AfterViewChecked, Inject, forwardRef } from "@angular/core";
+import { Component, Output, EventEmitter, AfterViewChecked, Inject, forwardRef, Input } from "@angular/core";
 
 import { FormulaireDefinition } from "../../formulaire/definition/form-definition";
 import { CalculatorResults } from "../../results/calculator-results";
@@ -20,7 +20,7 @@ export class CalculatorResultsComponent implements AfterViewChecked {
         @Inject(forwardRef(() => GenericCalculatorComponent)) private calculatorComponent: GenericCalculatorComponent
     ) { }
 
-    // @TODO @Input() ?
+    @Input()
     public set formulaire(f: FormulaireDefinition) {
         this._formulaire = f;
     }
diff --git a/src/app/components/generic-calculator/calc-name.component.ts b/src/app/components/generic-calculator/calc-name.component.ts
index a07f51b0c..c1cc4bb7e 100644
--- a/src/app/components/generic-calculator/calc-name.component.ts
+++ b/src/app/components/generic-calculator/calc-name.component.ts
@@ -1,4 +1,4 @@
-import { Component } from "@angular/core";
+import { Component, Input } from "@angular/core";
 import { GenericInputComponentDirective } from "../generic-input/generic-input.component";
 import { FormulaireDefinition } from "../../formulaire/definition/form-definition";
 import { I18nService } from "../../services/internationalisation.service";
@@ -20,6 +20,11 @@ export class CalculatorNameComponent extends GenericInputComponentDirective {
         super(null, intlService, appSetupService);
     }
 
+    @Input()
+    public set model(v: any) {
+        super.model = v;
+    }
+
     /**
      * formulaire géré
      */
diff --git a/src/app/components/generic-calculator/calculator.component.html b/src/app/components/generic-calculator/calculator.component.html
index 906fc6a98..7b085815a 100644
--- a/src/app/components/generic-calculator/calculator.component.html
+++ b/src/app/components/generic-calculator/calculator.component.html
@@ -57,7 +57,7 @@
         <mat-card-content>
 
             <!-- nom du module de calcul -->
-            <calc-name id="calculator-name" [title]="uitextCalculatorName"></calc-name>
+            <calc-name id="calculator-name" [model]="formulaire" [title]="uitextCalculatorName"></calc-name>
 
             <button mat-raised-button type="button" color="accent" id="load-predefined-espece" *ngIf="isEspece"
                 (click)="loadPredefinedEspece()" [title]="uitextLoadPredefinedEspece">
@@ -192,7 +192,7 @@
                     </button>
 
                     <mat-card-content>
-                        <calc-results id="resultsComp" (afterViewChecked)="onCalcResultsViewChecked()"></calc-results>
+                        <calc-results id="resultsComp" [formulaire]="formulaire" (afterViewChecked)="onCalcResultsViewChecked()"></calc-results>
                     </mat-card-content>
                 </mat-card>
 
diff --git a/src/app/components/generic-calculator/calculator.component.ts b/src/app/components/generic-calculator/calculator.component.ts
index 2cd8d2d6f..33efee506 100644
--- a/src/app/components/generic-calculator/calculator.component.ts
+++ b/src/app/components/generic-calculator/calculator.component.ts
@@ -31,10 +31,8 @@ import { ApplicationSetupService } from "../../services/app-setup.service";
 import { I18nService } from "../../services/internationalisation.service";
 import { FieldSet } from "../../formulaire/elements/fieldset";
 import { FormulaireDefinition } from "../../formulaire/definition/form-definition";
-import { CalculatorResultsComponent } from "../../components/calculator-results/calculator-results.component";
 import { Subscription } from "rxjs";
 import { FieldSetComponent } from "../field-set/field-set.component";
-import { CalculatorNameComponent } from "./calc-name.component";
 import { FormulaireElement } from "../../formulaire/elements/formulaire-element";
 import { FieldsetContainer } from "../../formulaire/elements/fieldset-container";
 import { FieldsetContainerComponent } from "../fieldset-container/fieldset-container.component";
@@ -46,7 +44,6 @@ import { DialogGeneratePARSimulationComponent } from "../dialog-generate-par-sim
 import { DialogLoadPredefinedEspeceComponent } from "../dialog-load-predefined-espece/dialog-load-predefined-espece.component";
 import { PabTable } from "../../formulaire/elements/pab-table";
 import { MultiDimensionResults } from "../../results/multidimension-results";
-import { NgParameter } from "../../formulaire/elements/ngparam";
 import { FormulaireFixedVar } from "../../formulaire/definition/form-fixedvar";
 import { PbSchema } from "../../formulaire/elements/pb-schema";
 import { PbSchemaComponent } from "../pb-schema/pb-schema.component";
@@ -86,18 +83,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
     @ViewChild(PbSchemaComponent)
     private _pbSchemaComponent: PbSchemaComponent;
 
-    /**
-     * composant d'affichage des résultats
-     */
-    @ViewChild(CalculatorResultsComponent, { static: true })
-    private resultsComponent: CalculatorResultsComponent;
-
-    /**
-     * composant "nom du module de calcul"
-     */
-    @ViewChild(CalculatorNameComponent, { static: true })
-    private _calculatorNameComponent: CalculatorNameComponent;
-
     /**
      * formulaire affiché
      */
@@ -179,6 +164,10 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
         }, this)));
     }
 
+    public get formulaire(): FormulaireDefinition {
+        return this._formulaire;
+    }
+
     public get formElements(): FormulaireElement[] {
         if (this._formulaire === undefined) {
             return [];
@@ -447,8 +436,6 @@ export class GenericCalculatorComponent implements OnInit, DoCheck, AfterViewChe
                 case "currentFormChanged":
                     const uid: string = data["formId"];
                     this._formulaire = (this.formulaireService.getFormulaireFromId(uid));
-                    this.resultsComponent.formulaire = this._formulaire;
-                    this._calculatorNameComponent.model = this._formulaire;
                     // reload localisation in all cases (it does not eat bread)
                     this.formulaireService.updateFormulaireLocalisation(this._formulaire);
                     break;
-- 
GitLab


From a552413c50c0fcf95ac5fc68ae871bfdb3b67e94 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Thu, 17 Sep 2020 10:55:10 +0200
Subject: [PATCH 12/12] Cosmetics

---
 .../jet-trajectory-chart/jet-trajectory-chart.component.html    | 2 +-
 .../jet-trajectory-chart/jet-trajectory-chart.component.ts      | 1 -
 .../pab-profile-chart/pab-profile-chart.component.html          | 2 +-
 src/app/components/results-chart/results-chart.component.html   | 2 +-
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.html b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.html
index 1087a424a..cedbcf293 100644
--- a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.html
+++ b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.html
@@ -17,7 +17,7 @@
         </div>
 
         <div *ngIf="! displayChart" class="fake-chart"></div><!-- trick to avoid blinking effect due to forceRebuild -->
-        <chart *ngIf="displayChart" type="scatter" [data]="graph_data" [options]="graph_options" #graphChart>
+        <chart *ngIf="displayChart" type="scatter" [data]="graph_data" [options]="graph_options">
         </chart>
     </div>
 </div>
\ No newline at end of file
diff --git a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
index 3e4d1e9db..2d726e9f9 100644
--- a/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
+++ b/src/app/components/jet-trajectory-chart/jet-trajectory-chart.component.ts
@@ -138,7 +138,6 @@ export class JetTrajectoryChartComponent extends ResultsComponentDirective imple
 
     // redessine le graphique dès qu'une entrée change
     public ngOnChanges() {
-        console.log("----> regenerate trajectory chart !!");
         if (this._results) {
             const nub = this._results.sourceNub as Jet;
             const length = nub.variatingLength();
diff --git a/src/app/components/pab-profile-chart/pab-profile-chart.component.html b/src/app/components/pab-profile-chart/pab-profile-chart.component.html
index 35c9c9aec..f7c4d9079 100644
--- a/src/app/components/pab-profile-chart/pab-profile-chart.component.html
+++ b/src/app/components/pab-profile-chart/pab-profile-chart.component.html
@@ -16,7 +16,7 @@
             </button>
         </div>
 
-        <chart type="scatter" [data]="graph_data" [options]="graph_options" #graphChart>
+        <chart type="scatter" [data]="graph_data" [options]="graph_options">
         </chart>
     </div>
 </div>
\ No newline at end of file
diff --git a/src/app/components/results-chart/results-chart.component.html b/src/app/components/results-chart/results-chart.component.html
index 1cf1336d5..be55ade02 100644
--- a/src/app/components/results-chart/results-chart.component.html
+++ b/src/app/components/results-chart/results-chart.component.html
@@ -17,7 +17,7 @@
         </div>
 
         <div *ngIf="! displayChart" class="fake-chart"></div><!-- trick to avoid blinking effect due to forceRebuild -->
-        <chart *ngIf="displayChart" [type]="graph_type" [data]="graph_data" [options]="graph_options" #graphChart>
+        <chart *ngIf="displayChart" [type]="graph_type" [data]="graph_data" [options]="graph_options">
         </chart>
     </div>
 </div>
-- 
GitLab