From bf1757b206e6094bb4b344374c03fb827ebefae5 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Wed, 23 Oct 2019 17:48:20 +0200
Subject: [PATCH 1/2] Update jalhyd_branch

---
 jalhyd_branch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jalhyd_branch b/jalhyd_branch
index 4517376e6..ea6e11283 100644
--- a/jalhyd_branch
+++ b/jalhyd_branch
@@ -1 +1 @@
-152-solveur-multi-modules
+147-remous-il-manque-parfois-une-abscisse
-- 
GitLab


From d55be0ec2951a3839f37acae56b78b6ae5cf820b Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Thu, 24 Oct 2019 12:05:41 +0200
Subject: [PATCH 2/2] Fix #312 - Remous: short "ressaut"

convert Remous main chart to scatter
---
 .../remous-results.component.ts               | 99 ++++++++++++++++---
 1 file changed, 84 insertions(+), 15 deletions(-)

diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts
index a710067a4..650c5ff5c 100644
--- a/src/app/components/remous-results/remous-results.component.ts
+++ b/src/app/components/remous-results/remous-results.component.ts
@@ -23,7 +23,7 @@ class LineData {
     /**
      * orodonnées
      */
-    private _ty: number[] = [];
+    private _ty: any[] = [];
 
     /**
      * graphe auquel aapartient la ligne
@@ -33,7 +33,7 @@ class LineData {
     /**
      * données fournies à ChartJS
      */
-    private _data = {};
+    private _data: any = {};
 
     /**
      * profondeur à laquelle est dessinée la ligne
@@ -51,12 +51,29 @@ class LineData {
 
     public getYat(x: number) {
         const i = this._tx.indexOf(x);
-        return this._ty[i];
+        if (Array.isArray(this._ty[i])) {
+            return this._ty[i][0];
+        } else {
+            return this._ty[i];
+        }
     }
 
-    public setPoint(x: number, y: number) {
+    public setPoint(x: number, y: number, reverse: boolean = false) {
         const i = this._tx.indexOf(x);
-        this._ty[i] = y;
+        // already a value ?
+        if (this._ty[i] !== null) {
+            // not already an Array ?
+            if (! Array.isArray(this._ty[i])) {
+                this._ty[i] = [ this._ty[i] ];
+            }
+            if (reverse) {
+                this._ty[i].unshift(y);
+            } else {
+                this._ty[i].push(y);
+            }
+        } else {
+            this._ty[i] = y;
+        }
     }
 
     public mapPoint(x: number, y: number) {
@@ -81,7 +98,28 @@ class LineData {
     }
 
     public get data() {
-        return this._data;
+        const scatterData = [];
+        for (let i = 0; i < this._data.data.length; i++) {
+            const d = this._data.data[i];
+            const x = this._tx[i];
+            if (Array.isArray(d)) {
+                for (const dd of d) {
+                    scatterData.push({
+                        x: x,
+                        y: dd
+                    });
+                }
+            } else {
+                scatterData.push({
+                    x: x,
+                    y: d
+                });
+            }
+        }
+        const dataCopy = JSON.parse(JSON.stringify(this._data));
+        dataCopy.data = scatterData;
+        return dataCopy;
+        // return this._data;
     }
 
     public set data(d: {}) {
@@ -175,7 +213,7 @@ class ChartData {
         l.setPoint(this._longBief, ymax);
         l.data = {
             label: lbl, fill: fillColor !== undefined, tension: 0, spanGaps: true,
-            borderColor: color, backgroundColor: fillColor, pointRadius: 0
+            borderColor: color, backgroundColor: fillColor, pointRadius: 0, showLine: "true"
         };
     }
 
@@ -216,7 +254,7 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck
     /*
     * config du graphe principal
     */
-    public graph1_type = "line";
+    public graph1_type = "scatter";
     public graph1_data = {};
     public graph1_options = {};
 
@@ -401,21 +439,41 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck
         if (lineFlu !== undefined && lineTor !== undefined) {
             const p = this._remousResults.varResults.variatedParameters[0].paramDefinition;
             const xs = p.getInferredValuesList();
-            // 1e passe : prolonger la torrentielle
+            // 1e passe : trouver combien d'abscisses en commun
+            let aec = 0;
+            for (const x of xs) {
+                if (
+                    (lineTor.getYat(x) !== null)
+                    && (lineFlu.getYat(x) !== null)
+                ) {
+                    aec++;
+                }
+            }
+            // 2e passe : prolonger la torrentielle
             outerloop1:
             for (let i = 0; i < xs.length; i++) {
                 const x = xs[i];
                 if (lineTor.getYat(x) === null) {
-                    lineTor.setPoint(x, lineFlu.getYat(x));
+                    if (aec === 1 && i > 0) {
+                        // une seule abscisse en commun, cas particulier: connexion verticale
+                        lineTor.setPoint(xs[i - 1], lineFlu.getYat(xs[i - 1]));
+                    } else {
+                        lineTor.setPoint(x, lineFlu.getYat(x));
+                    }
                     break outerloop1;
                 }
             }
-            // 2e passe : prolonger la fluviale
+            // 3e passe : prolonger la fluviale
             outerloop2:
             for (let i = xs.length - 1; i >= 0; i--) {
                 const x = xs[i];
                 if (lineFlu.getYat(x) === null) {
-                    lineFlu.setPoint(x, lineTor.getYat(x));
+                    if (aec === 1 && i < (xs.length - 1)) {
+                        // une seule abscisse en commun, cas particulier: connexion verticale
+                        lineFlu.setPoint(xs[i + 1], lineTor.getYat(xs[i + 1]), true);
+                    } else {
+                        lineFlu.setPoint(x, lineTor.getYat(x));
+                    }
                     break outerloop2;
                 }
             }
@@ -537,7 +595,7 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck
             } else {
                 lineExtra.data = {
                     label: this.extraParamLabel,
-                    tension: 0, fill: false, spanGaps: true, borderColor: "#C17AF0", pointRadius: 4
+                    tension: 0, fill: false, spanGaps: true, borderColor: "#C17AF0", pointRadius: 4, showLine: "true"
                 };
             }
         }
@@ -553,7 +611,8 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck
                 borderColor: "#77A3CD",
                 pointBackgroundColor: "#77A3CD",
                 pointRadius: 4,
-                backgroundColor: "#D1D0D4"
+                backgroundColor: "#D1D0D4",
+                showLine: "true"
             };
         }
         if (lineFlu !== undefined) {
@@ -563,7 +622,8 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck
                 borderColor: "#0093BD",
                 pointBackgroundColor: "#0093BD",
                 pointRadius: 4,
-                backgroundColor: "#D1D0D4"
+                backgroundColor: "#D1D0D4",
+                showLine: "true"
             };
         }
 
@@ -582,6 +642,8 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck
             scales: {
                 xAxes: [{
                     gridLines: {
+                        display: true,
+                        color: "rgba(255,99,132,0.2)",
                         offsetGridLines: true
                     },
                     ticks: {
@@ -594,6 +656,13 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck
                         display: true,
                         labelString: this.uitextAbscisse
                     }
+                }],
+                yAxes: [{
+                    // stacked: true,
+                    gridLines: {
+                      display: true,
+                      color: "rgba(255,99,132,0.2)"
+                    }
                 }]
             },
             tooltips: {
-- 
GitLab