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 921eea44024068e76c581723fe2b45eb28c25753..7018d0e95bac4c60ba58e0f54b76555b0cf98d46 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 @@ -16,6 +16,12 @@ export class PabProfileGraphComponent extends ResultsComponent { private _results: PabResults; + /** size of the longest variable value */ + private size = 0; + + /** inferred extended values list for each variating parameter */ + private varValues = []; + /* * config du graphe */ @@ -27,7 +33,9 @@ export class PabProfileGraphComponent extends ResultsComponent { duration: 0 }, legend: { - display: false + display: true, + position: "bottom", + reverse: false }, title: { display: true, @@ -41,7 +49,7 @@ export class PabProfileGraphComponent extends ResultsComponent { }; public constructor( - private appSetup: ApplicationSetupService, + private appSetupService: ApplicationSetupService, private intlService: I18nService ) { super(); @@ -49,6 +57,28 @@ export class PabProfileGraphComponent extends ResultsComponent { 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; + } + } + // 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); + } } public updateView() { @@ -60,7 +90,7 @@ export class PabProfileGraphComponent extends ResultsComponent { * génère les données d'un graphe de type "scatter" */ private generateScatterGraph() { - const nDigits = this.appSetup.displayDigits; + const nDigits = this.appSetupService.displayDigits; const ySeries = this.getYSeries(); this.graph_data = { datasets: [] @@ -142,7 +172,7 @@ export class PabProfileGraphComponent extends ResultsComponent { private getXSeries(): string[] { const data: string[] = []; - const nDigits = this.appSetup.displayDigits; + const nDigits = this.appSetupService.displayDigits; // X is always wall abscissa for (const cr of this._results.cloisonsResults) { const x = cr.resultElement.getExtraResult("x"); // any resultElement will do @@ -161,7 +191,7 @@ export class PabProfileGraphComponent extends ResultsComponent { // 1. fond du machin const dataF: { x: string, y: string }[] = []; - const nDigits = this.appSetup.displayDigits; + const nDigits = this.appSetupService.displayDigits; // extend upstrem dataF.push({ x: (Number(xs[0]) - pabLength5Pct).toFixed(nDigits), @@ -190,8 +220,8 @@ export class PabProfileGraphComponent extends ResultsComponent { // add series ret.push({ data: dataF, - label: "fond du machin", - color: "#000000" + label: this.intlService.localizeText("INFO_LIB_RADIER"), + color: "#808080" }); // 2. séries @@ -248,7 +278,11 @@ export class PabProfileGraphComponent extends ResultsComponent { ret.push({ data: dataN, - label: "série " + n, + label: ( + this._results.variatedParameters.length > 0 ? + this.getLegendForSeries(n) : + this.intlService.localizeText("INFO_LIB_LIGNE_D_EAU") + ), color: palette[ n % palette.length ] }); } @@ -256,6 +290,22 @@ export class PabProfileGraphComponent extends ResultsComponent { return ret; } + /** + * Returns a label showing the boundary conditions values for + * the given iteration + * @param n index of the variating parameter(s) iteration + */ + private getLegendForSeries(n: number): string { + let i = 0; + return this.varValues.map((vv) => { + const vp = this._results.variatedParameters[i]; + i++; + let value = "0"; + value = vv[n]; + return `${vp.symbol} = ${value}`; + }).join(", "); + } + /** * 14 distinct colors @see https://sashat.me/2017/01/11/list-of-20-simple-distinct-colors */ diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 7547a0ac62219cc1965714f48bf12e054ed1c059..7c51c408a11e5ec584485120945e64c34c8e9fae 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -146,6 +146,7 @@ "INFO_LIB_J": "Head loss", "INFO_LIB_L": "Weir width", "INFO_LIB_LB": "Pool length", + "INFO_LIB_LIGNE_D_EAU": "Water line", "INFO_LIB_MINZDV": "Minimal crest elevation", "INFO_LIB_MAXZDV": "Maximal crest elevation", "INFO_LIB_OUVRAGE_Q_ENUM_STRUCTUREFLOWMODE": "Mode", @@ -161,6 +162,7 @@ "INFO_LIB_QA": "Attraction flow", "INFO_LIB_R": "Hydraulic radius", "INFO_LIB_S": "Orifice area", + "INFO_LIB_RADIER": "Basin bottom", "INFO_LIB_SELECT_LOIDEBIT": "Stage-discharge law", "INFO_LIB_SELECT_LOIDEBIT1_KIVI": "Kindsvater-Carter and Villemonte", "INFO_LIB_SELECT_LOIDEBIT1": "Stage-discharge law", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 291911464e6d17e7f89fa8ecea3067afd97faf69..3332e729bd9041badc522d3ddf026a2a94a05f3f 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -146,6 +146,7 @@ "INFO_LIB_J": "Perte de charge", "INFO_LIB_L": "Largeur du déversoir", "INFO_LIB_LB": "Longueur du bassin", + "INFO_LIB_LIGNE_D_EAU": "Ligne d'eau", "INFO_LIB_MINZDV": "Cote minimale de la crête", "INFO_LIB_MAXZDV": "Cote maximale de la crête", "INFO_LIB_OUVRAGE_Q_ENUM_STRUCTUREFLOWMODE": "Type d'écoulement", @@ -160,6 +161,7 @@ "INFO_LIB_Q": "Débit", "INFO_LIB_QA": "Débit d'attrait", "INFO_LIB_R": "Rayon hydraulique", + "INFO_LIB_RADIER": "Radier", "INFO_LIB_S": "Surface de l'orifice", "INFO_LIB_SELECT_LOIDEBIT": "Loi de débit", "INFO_LIB_SELECT_LOIDEBIT1_KIVI": "Kindsvater-Carter et Villemonte",