diff --git a/src/app/components/pb-schema/pb-schema.component.ts b/src/app/components/pb-schema/pb-schema.component.ts index 0da9aee8c0e03f496c12ac25b1883564b8890952..9a3ed0edc8015c02287d1394682c766d17513056 100644 --- a/src/app/components/pb-schema/pb-schema.component.ts +++ b/src/app/components/pb-schema/pb-schema.component.ts @@ -179,8 +179,50 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni const def: string[] = [ "graph TB" ]; // river upstream / downstream - def.push(`${this.upstreamId}("${this.i18nService.localizeText("INFO_LIB_AMONT")}")`); - def.push(`${this.downstreamId}("${this.i18nService.localizeText("INFO_LIB_AVAL")}")`); + let upstreamLabel = this.i18nService.localizeText("INFO_LIB_AMONT"); + let downstreamLabel = this.i18nService.localizeText("INFO_LIB_AVAL"); + // add result data Z and Q, if any + if ( + this.model?.result?.resultElements + && this.model.result.resultElements[0]?.ok + ) { + // when a parameter is variating, index of the variating parameter + // values to build the data from + const form = this.calculatorComponent.formulaire as FormulairePrebarrage; + const idx = form.pbResults.variableIndex; + const qValue = this.model.prms.Q.isCalculated + ? this.model.result.resultElements[idx].vCalc + : ( + this.model.prms.Q.hasMultipleValues + ? this.model.prms.Q.getInferredValuesList(this.model.variatingLength())[idx] + : this.model.prms.Q.singleValue + ); + // upstream + upstreamLabel += "<br>"; + upstreamLabel += "Q = " + fv(qValue); + upstreamLabel += "<br>"; + upstreamLabel += "Z = " + fv( + this.model.prms.Z1.isCalculated + ? this.model.result.resultElements[idx].vCalc + : ( + this.model.prms.Z1.hasMultipleValues + ? this.model.prms.Z1.getInferredValuesList(this.model.variatingLength())[idx] + : this.model.prms.Z1.singleValue + ) + ); + // downstream + downstreamLabel += "<br>"; + downstreamLabel += "Q = " + fv(qValue); + downstreamLabel += "<br>"; + downstreamLabel += "Z = " + fv( + this.model.prms.Z2.hasMultipleValues + ? this.model.prms.Z2.getInferredValuesList(this.model.variatingLength())[idx] + : this.model.prms.Z2.sin + ); + } + // add to graph definition + def.push(`${this.upstreamId}("${upstreamLabel}")`); + def.push(`${this.downstreamId}("${downstreamLabel}")`); // styles def.push("classDef wall fill:#e8e8e8,stroke-width:0;"); @@ -322,11 +364,7 @@ export class PbSchemaComponent implements AfterViewInit, AfterContentInit, OnIni const idx = form.pbResults.variableIndex; iDesc += "<br>"; if (item instanceof PbCloison) { - iDesc += "Q = " + fv( - item.prms.Q.isCalculated - ? item.result.resultElements[idx].vCalc - : item.prms.Q.getInferredValuesList(this.model.variatingLength())[idx] - ); + iDesc += "Q = " + fv(item.result.resultElements[idx].vCalc); // Q is always the vCalc of PbCloison iDesc += "<br>"; iDesc += "DH = " + fv(item.result.resultElements[idx].values.DH); } else if (item instanceof PbBassin) {