From 7dbca63a44a913d758aaa9ccb0bcbb59ca6efc59 Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Wed, 10 Jul 2019 16:10:15 +0200
Subject: [PATCH] =?UTF-8?q?#234=20:=20ajout=20l=C3=A9gende=20des=20axes?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../pab-profile-graph.component.ts            | 91 ++++++++++---------
 src/locale/messages.en.json                   |  2 +
 src/locale/messages.fr.json                   |  2 +
 3 files changed, 50 insertions(+), 45 deletions(-)

diff --git a/src/app/components/pab-profile-graph/pab-profile-graph.component.ts b/src/app/components/pab-profile-graph/pab-profile-graph.component.ts
index 7018d0e95..07f3f8553 100644
--- a/src/app/components/pab-profile-graph/pab-profile-graph.component.ts
+++ b/src/app/components/pab-profile-graph/pab-profile-graph.component.ts
@@ -53,31 +53,59 @@ export class PabProfileGraphComponent extends ResultsComponent {
         private intlService: I18nService
     ) {
         super();
+        const nDigits = this.appSetupService.displayDigits;
+        // do not move following block out of constructor or scale labels won't be rendered
+        this.graph_options["scales"] = {
+            xAxes: [{
+                type: "linear",
+                position: "bottom",
+                ticks: {
+                    precision: nDigits
+                },
+                scaleLabel: {
+                    display: true,
+                    labelString: this.intlService.localizeText("INFO_LIB_DISTANCE_AMONT")
+                }
+            }],
+            yAxes: [{
+                type: "linear",
+                position: "left",
+                ticks: {
+                    precision: nDigits
+                },
+                scaleLabel: {
+                    display: true,
+                    labelString: this.intlService.localizeText("INFO_LIB_COTE")
+                }
+            }]
+        };
     }
 
     public set results(r: PabResults) {
         this._results = r;
 
         // pre-extract variable parameters values
-        this.varValues = [];
-        const nDigits = this.appSetupService.displayDigits;
-        // find longest list
-        this.size = 0;
-        for (let i = 0; i < this._results.variatedParameters.length; i++) {
-            const vs = this._results.variatedParameters[i].valuesIterator.count();
-            if (vs > this.size) {
-                this.size = vs;
+        if (this._results) {
+            this.varValues = [];
+            const nDigits = this.appSetupService.displayDigits;
+            // find longest list
+            this.size = 0;
+            for (let i = 0; i < this._results.variatedParameters.length; i++) {
+                const vs = this._results.variatedParameters[i].valuesIterator.count();
+                if (vs > this.size) {
+                    this.size = vs;
+                }
             }
-        }
-        // get extended values lists for each variable parameter
-        for (const v of this._results.variatedParameters) {
-            const vv = [];
-            const iter = v.getExtendedValuesIterator(this.size);
-            while (iter.hasNext) {
-                const nv = iter.next();
-                vv.push(nv.value.toFixed(nDigits));
+            // get extended values lists for each variable parameter
+            for (const v of this._results.variatedParameters) {
+                const vv = [];
+                const iter = v.getExtendedValuesIterator(this.size);
+                while (iter.hasNext) {
+                    const nv = iter.next();
+                    vv.push(nv.value.toFixed(nDigits));
+                }
+                this.varValues.push(vv);
             }
-            this.varValues.push(vv);
         }
     }
 
@@ -90,39 +118,12 @@ export class PabProfileGraphComponent extends ResultsComponent {
      * génère les données d'un graphe de type "scatter"
      */
     private generateScatterGraph() {
-        const nDigits = this.appSetupService.displayDigits;
         const ySeries = this.getYSeries();
+
         this.graph_data = {
             datasets: []
         };
 
-        this.graph_options["scales"] = {
-            xAxes: [{
-                type: "linear",
-                position: "bottom",
-                ticks: {
-                    precision: nDigits
-                },
-                scaleLabel: {
-                    display: true,
-                    labelString: "la super abscisse"
-                    // labelString: this.axisLabelWithoutSymbol(this.chartX)
-                }
-            }],
-            yAxes: [{
-                type: "linear",
-                position: "left",
-                ticks: {
-                    precision: nDigits
-                },
-                scaleLabel: {
-                    display: true,
-                    labelString: "la super ordonnée"
-                    /// labelString: this.axisLabelWithoutSymbol(this.chartY)
-                }
-            }]
-        };
-
         // build Y data series
         for (const ys of ySeries) {
             // push series config
diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json
index 7c51c408a..b350b695e 100644
--- a/src/locale/messages.en.json
+++ b/src/locale/messages.en.json
@@ -126,11 +126,13 @@
     "INFO_LIB_BT": "Half opening of the triangle",
     "INFO_LIB_CD": "Discharge coefficient",
     "INFO_LIB_CLOISON": "Cross wall #",
+    "INFO_LIB_COTE": "Elevation (m)",
     "INFO_LIB_COTE_VANNE_LEVANTE": "Lift gate elevation",
     "INFO_LIB_CV": "Cv: Velocity coefficient",
     "INFO_LIB_CVQT": "CV.QT: Corrected discharge",
     "INFO_LIB_DH": "Fall",
     "INFO_LIB_DHR": "DHR : Residual fall",
+    "INFO_LIB_DISTANCE_AMONT": "Distance from upstream (m)",
     "INFO_LIB_EC": "EC: Kinetic energy",
     "INFO_LIB_ENUM_MACRORUGOFLOWTYPE": "Flow type",
     "INFO_LIB_FLU": "Subcritical water line",
diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json
index 3332e729b..55e62e3f6 100644
--- a/src/locale/messages.fr.json
+++ b/src/locale/messages.fr.json
@@ -126,11 +126,13 @@
     "INFO_LIB_BT": "Demi-ouverture du triangle",
     "INFO_LIB_CD": "Coefficient de débit",
     "INFO_LIB_CLOISON": "Cloison n°",
+    "INFO_LIB_COTE": "Cote (m)",
     "INFO_LIB_COTE_VANNE_LEVANTE": "Cote vanne levante",
     "INFO_LIB_CV": "Cv: Coefficient de vitesse d'approche",
     "INFO_LIB_CVQT": "CV.QT: Débit corrigé",
     "INFO_LIB_DH": "Chute",
     "INFO_LIB_DHR": "DHR: Chute résiduelle",
+    "INFO_LIB_DISTANCE_AMONT": "Distance depuis l'amont (m)",
     "INFO_LIB_EC": "EC: Énergie cinétique",
     "INFO_LIB_ENUM_MACRORUGOFLOWTYPE": "Type d'écoulement",
     "INFO_LIB_FLU": "Ligne d'eau fluviale",
-- 
GitLab