From ae1b8fe01b4433467359885dccd69c84db4d11e2 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Tue, 14 May 2019 15:11:09 +0200 Subject: [PATCH] Graphique pour la PAB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit amélioration du composant ResultsGraph nouvelle interface PlottableData --- .../pab-results-table.component.ts | 37 ++-- .../pab-results/pab-results.component.html | 2 +- .../pab-results/pab-results.component.ts | 35 +++- .../results-graph/graph-type.component.ts | 2 +- .../results-graph/results-graph.component.ts | 19 +- .../formulaire/definition/form-compute-pab.ts | 21 ++ .../definition/form-result-fixedvar.ts | 3 +- src/app/results/graph-type.ts | 19 ++ src/app/results/pab-results.ts | 35 +++- src/app/results/plottable-data.ts | 30 +++ src/app/results/plottable-pab-results.ts | 193 ++++++++++++++++++ src/app/results/var-results.ts | 40 ++-- 12 files changed, 363 insertions(+), 73 deletions(-) create mode 100644 src/app/results/graph-type.ts create mode 100644 src/app/results/plottable-data.ts create mode 100644 src/app/results/plottable-pab-results.ts 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 a52b6acf5..d598ae9bc 100644 --- a/src/app/components/pab-results/pab-results-table.component.ts +++ b/src/app/components/pab-results/pab-results-table.component.ts @@ -39,27 +39,18 @@ export class PabResultsTableComponent { public set results(r: PabResults) { this._pabResults = r; - // refresh headers here if language changed - this._headers = [ - this.intlService.localizeText("INFO_EXTRARES_LIB_CLOISON"), - this.intlService.localizeText("INFO_EXTRARES_LIB_DH"), - this.intlService.localizeText("INFO_EXTRARES_LIB_ZR"), - this.intlService.localizeText("INFO_EXTRARES_LIB_Q"), - this.intlService.localizeText("INFO_EXTRARES_LIB_Z1_PAB"), - this.intlService.localizeText("INFO_EXTRARES_LIB_PV"), - this.intlService.localizeText("INFO_EXTRARES_LIB_TMOY"), - this.intlService.localizeText("INFO_EXTRARES_LIB_ZRB"), - this.intlService.localizeText("INFO_EXTRARES_LIB_QA") - ]; - this._dataSet = []; if (this._pabResults && this._pabResults.cloisonsResults && this._pabResults.cloisonsResults.length > 0) { const pr = this._pabResults; const nDigits = this.appSetupService.displayDigits; + + // refresh headers here if language changed + this._headers = pr.headers; + // line 1 this._dataSet.push([ "", "", "", "", - this._pabResults.cloisonsResults[0] ? this._pabResults.cloisonsResults[0].vCalc.toFixed(nDigits) : "X", + this._pabResults.cloisonsResults[0] ? this._pabResults.cloisonsResults[0].vCalc.toFixed(nDigits) : "", "", "", "", "" ]); @@ -74,12 +65,12 @@ export class PabResultsTableComponent { this._dataSet.push([ i + 1, (pr.cloisonsResults[i].vCalc - pr.cloisonsResults[i + 1].vCalc).toFixed(nDigits), - (ZRAM !== undefined) ? ZRAM.toFixed(nDigits) : "X", + (ZRAM !== undefined) ? ZRAM.toFixed(nDigits) : "", pr.cloisonsQ[i].toFixed(nDigits), pr.cloisonsResults[i + 1].vCalc.toFixed(nDigits), - (PV !== undefined) ? PV.toFixed(nDigits) : "X", - (Y !== undefined) ? Y.toFixed(nDigits) : "X", - (ZRB !== undefined) ? ZRB.toFixed(nDigits) : "X", + (PV !== undefined) ? PV.toFixed(nDigits) : "", + (Y !== undefined) ? Y.toFixed(nDigits) : "", + (ZRB !== undefined) ? ZRB.toFixed(nDigits) : "", pr.bassinsQA[i] ]); } @@ -93,12 +84,12 @@ export class PabResultsTableComponent { this._dataSet.push([ l, (pr.cloisonsResults[l - 1].vCalc - pr.cloisonAvalResults.vCalc).toFixed(nDigits), - (nZRAM !== undefined) ? nZRAM.toFixed(nDigits) : "X", + (nZRAM !== undefined) ? nZRAM.toFixed(nDigits) : "", pr.cloisonsQ[l - 1].toFixed(nDigits), pr.cloisonAvalResults.vCalc.toFixed(nDigits), - (nPV !== undefined) ? nPV.toFixed(nDigits) : "X", - (nY !== undefined) ? nY.toFixed(nDigits) : "X", - (nZRB !== undefined) ? nZRB.toFixed(nDigits) : "X", + (nPV !== undefined) ? nPV.toFixed(nDigits) : "", + (nY !== undefined) ? nY.toFixed(nDigits) : "", + (nZRB !== undefined) ? nZRB.toFixed(nDigits) : "", pr.bassinsQA[l - 1] ]); @@ -107,7 +98,7 @@ export class PabResultsTableComponent { this._dataSet.push([ this.intlService.localizeText("INFO_EXTRARES_LIB_AVAL"), (pr.cloisonAvalResults.vCalc - pr.Z2).toFixed(nDigits), - (caZRAM !== undefined) ? caZRAM.toFixed(nDigits) : "X", + (caZRAM !== undefined) ? caZRAM.toFixed(nDigits) : "", pr.cloisonAvalQ.toFixed(nDigits), pr.Z2.toFixed(nDigits), "", diff --git a/src/app/components/pab-results/pab-results.component.html b/src/app/components/pab-results/pab-results.component.html index 02aa6f94e..9fcc9927c 100644 --- a/src/app/components/pab-results/pab-results.component.html +++ b/src/app/components/pab-results/pab-results.component.html @@ -2,7 +2,7 @@ <!-- journal --> <log></log> - <!-- <results-graph *ngIf="showVarResults"></results-graph> --> + <results-graph *ngIf="hasResults"></results-graph> <div> <!-- tableau de résultats --> diff --git a/src/app/components/pab-results/pab-results.component.ts b/src/app/components/pab-results/pab-results.component.ts index 274ace58e..99517c236 100644 --- a/src/app/components/pab-results/pab-results.component.ts +++ b/src/app/components/pab-results/pab-results.component.ts @@ -1,12 +1,16 @@ import { Component, ViewChild, DoCheck } from "@angular/core"; +import { Result, cLog } from "jalhyd"; + import { LogComponent } from "../../components/log/log.component"; import { CalculatorResults } from "../../results/calculator-results"; -import { Result, cLog } from "jalhyd"; import { NgParameter } from "../../formulaire/ngparam"; import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; import { PabResultsTableComponent } from "./pab-results-table.component"; import { PabResults } from "../../results/pab-results"; +import { ResultsGraphComponent } from "../results-graph/results-graph.component"; +import { PlottableData } from "../../results/plottable-data"; +import { PlottablePabResults } from "../../results/plottable-pab-results"; @Component({ selector: "pab-results", @@ -30,6 +34,10 @@ export class PabResultsComponent implements DoCheck { @ViewChild(LogComponent) private logComponent: LogComponent; + /** graphique dans le cas d'un paramètre à varier */ + @ViewChild(ResultsGraphComponent) + private resultsGraphComponent: ResultsGraphComponent; + constructor( private appSetupService: ApplicationSetupService, ) { } @@ -47,6 +55,9 @@ export class PabResultsComponent implements DoCheck { if (this.pabResultsTableComponent) { this.pabResultsTableComponent.results = undefined; } + if (this.resultsGraphComponent) { + this.resultsGraphComponent.results = undefined; + } // set _doUpdate flag so that results are rebuilt on the next Angular display cycle this._doUpdate = false; if (this._pabResults !== undefined) { @@ -84,13 +95,20 @@ export class PabResultsComponent implements DoCheck { */ private updateResults() { let pabUpdated: boolean; + let graphUpdated: boolean; if (this.hasResults) { pabUpdated = this.pabResultsTableComponent !== undefined; if (pabUpdated) { this.pabResultsTableComponent.results = this._pabResults; } + graphUpdated = this.resultsGraphComponent !== undefined; + if (graphUpdated) { + this.resultsGraphComponent.results = this.plottableResults; + this.resultsGraphComponent.updateView(); + } } else { pabUpdated = true; + graphUpdated = true; } const logUpdated = this.logComponent !== undefined; @@ -98,14 +116,7 @@ export class PabResultsComponent implements DoCheck { this.logComponent.log = this.mergedGlobalLogs; } - return pabUpdated && logUpdated; - } - - /** - * affichage de la table des résultats de passe à bassins - */ - public get showPabResults(): boolean { - return this.hasResults; + return pabUpdated && logUpdated && graphUpdated; } public get pabResults() { @@ -124,4 +135,10 @@ export class PabResultsComponent implements DoCheck { public get hasResults(): boolean { return this._pabResults && this._pabResults.hasResults; } + + /** builds a set of PlottableData from PabResults, to feed the graph */ + protected get plottableResults(): PlottableData { + const pr = new PlottablePabResults(this._pabResults); + return pr; + } } diff --git a/src/app/components/results-graph/graph-type.component.ts b/src/app/components/results-graph/graph-type.component.ts index f5194120b..78ef5d486 100644 --- a/src/app/components/results-graph/graph-type.component.ts +++ b/src/app/components/results-graph/graph-type.component.ts @@ -1,7 +1,7 @@ import { Component } from "@angular/core"; import { Observable, IObservable, Observer } from "jalhyd"; -import { GraphType } from "../../results/var-results"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; +import { GraphType } from "../../results/graph-type"; @Component({ selector: "graph-type", diff --git a/src/app/components/results-graph/results-graph.component.ts b/src/app/components/results-graph/results-graph.component.ts index 13757e3bd..d0731c27b 100644 --- a/src/app/components/results-graph/results-graph.component.ts +++ b/src/app/components/results-graph/results-graph.component.ts @@ -2,10 +2,11 @@ import { Component, ViewChild, AfterContentInit } from "@angular/core"; import { Observer } from "jalhyd"; -import { VarResults, GraphType } from "../../results/var-results"; import { GraphTypeSelectComponent } from "./graph-type.component"; import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; +import { PlottableData } from "../../results/plottable-data"; +import { GraphType } from "../../results/graph-type"; @Component({ selector: "results-graph", @@ -15,7 +16,7 @@ import { I18nService } from "../../services/internationalisation/internationalis ] }) export class ResultsGraphComponent implements AfterContentInit, Observer { - private _results: VarResults; + private _results: PlottableData; @ViewChild(GraphTypeSelectComponent) private _graphTypeComponent: GraphTypeSelectComponent; @@ -53,7 +54,7 @@ export class ResultsGraphComponent implements AfterContentInit, Observer { const nDigits = this.appSetup.displayDigits; } - public set results(r: VarResults) { + public set results(r: PlottableData) { this._results = r; if (this._results && this._graphTypeComponent) { this._graphTypeComponent.selectedValue = r.graphType; @@ -98,17 +99,7 @@ export class ResultsGraphComponent implements AfterContentInit, Observer { * Returns a human readable description of any param / result symbol */ public getChartAxisLabel(symbol: string) { - // 1. calculated param ? - if (this._results.calculatedParameter && this._results.calculatedParameter.symbol === symbol) { - return this._results.calculatedParameterHeader; - } else - // 2. variated param ? - if (this._results.variatedParameter.symbol === symbol) { - return this._results.variableParamHeader; - } else { - // 3. Result element ? - return this.intlService.getExtraResLabel(symbol); - } + return this._results.getChartAxisLabel(symbol); } public get uitextSelectX() { diff --git a/src/app/formulaire/definition/form-compute-pab.ts b/src/app/formulaire/definition/form-compute-pab.ts index b1586759d..c5cfd59c2 100644 --- a/src/app/formulaire/definition/form-compute-pab.ts +++ b/src/app/formulaire/definition/form-compute-pab.ts @@ -15,6 +15,20 @@ export class FormComputePab extends FormCompute { return this._formResult as FormResultPab; } + private getVariatedParameter(): NgParameter { + const res = this._formBase.getDisplayedParamFromState(ParamRadioConfig.VAR); + if (res !== undefined) { + return res; + } + + const pms = this._formBase.getDisplayedParamListFromState(ParamRadioConfig.LINK); + for (const p of pms) { + if (p.paramDefinition.hasMultipleValues) { + return p; + } + } + } + protected compute() { this.runNubCalc(this._formBase.currentNub); this.reaffectResultComponents(); @@ -23,11 +37,13 @@ export class FormComputePab extends FormCompute { protected reaffectResultComponents() { const pab: Pab = (this._formBase.currentNub as Pab); const computedParam: NgParameter = this.getComputedParameter(); + const varParam: NgParameter = this.getVariatedParameter(); // résultat de calcul de la passe à bassins const pabr = this.formResult.pabResults; pabr.calculatedParameter = computedParam; pabr.result = pab.result; + // résultat de chaque cloison const cr: Result[] = []; // valeur de Q pour chaque cloison @@ -48,6 +64,11 @@ export class FormComputePab extends FormCompute { pabr.cloisonAvalQ = pab.downWall.prms.Q.v; // cote aval de la passe pabr.Z2 = pab.prms.Z2.v; + + if (varParam) { + pabr.variatedParameter = varParam; + // pabr.update(false); + } } private getComputedParameter(): NgParameter { diff --git a/src/app/formulaire/definition/form-result-fixedvar.ts b/src/app/formulaire/definition/form-result-fixedvar.ts index 53b9c455c..6a79f021e 100644 --- a/src/app/formulaire/definition/form-result-fixedvar.ts +++ b/src/app/formulaire/definition/form-result-fixedvar.ts @@ -1,9 +1,10 @@ import { FixedResults } from "../../results/fixed-results"; -import { GraphType, VarResults } from "../../results/var-results"; +import { VarResults } from "../../results/var-results"; import { ParamRadioConfig } from "../ngparam"; import { FormResult } from "./form-result"; import { FormulaireDefinition } from "./form-definition"; import { CalculatorResults } from "../../results/calculator-results"; +import { GraphType } from "../../results/graph-type"; export class FormResultFixedVar extends FormResult { /** diff --git a/src/app/results/graph-type.ts b/src/app/results/graph-type.ts new file mode 100644 index 000000000..cf83fc76e --- /dev/null +++ b/src/app/results/graph-type.ts @@ -0,0 +1,19 @@ +/** + * type de graphe + */ +export enum GraphType { + /** + * histogramme + */ + Histogram, + + /** + * points indépendants reliés par une courbe + */ + HistoLine, + + /** + * graphe XY classique + */ + Scatter, +} diff --git a/src/app/results/pab-results.ts b/src/app/results/pab-results.ts index 358aee845..e9b135981 100644 --- a/src/app/results/pab-results.ts +++ b/src/app/results/pab-results.ts @@ -1,6 +1,9 @@ -import { CalculatedParamResults } from "./param-calc-results"; import { Result } from "jalhyd"; +import { CalculatedParamResults } from "./param-calc-results"; +import { NgParameter } from "../formulaire/ngparam"; +import { ServiceFactory } from "../services/service-factory"; + export class PabResults extends CalculatedParamResults { /** résultats des modules Cloisons avant chaque bassin */ @@ -21,9 +24,39 @@ export class PabResults extends CalculatedParamResults { /** cote aval de l'ensemble de la passe */ public Z2: number; + /** paramètre varié */ + public variatedParameter: NgParameter; + + /** symboles des colonnes de résultat */ + protected _columns: string[]; + public constructor() { super(); this.reset(); + // standard headers + this._columns = [ + "CLOISON", + "DH", + "ZR", + "Q", + "Z1_PAB", + "PV", + "TMOY", + "ZRB", + "QA" + ]; + } + + /** headers symbols */ + public get columns() { + return this._columns; + } + + /** translated headers texts */ + public get headers() { + return this._columns.map((h) => { + return ServiceFactory.instance.i18nService.localizeText("INFO_EXTRARES_LIB_" + h); + }); } public reset() { diff --git a/src/app/results/plottable-data.ts b/src/app/results/plottable-data.ts new file mode 100644 index 000000000..609c388aa --- /dev/null +++ b/src/app/results/plottable-data.ts @@ -0,0 +1,30 @@ +import { GraphType } from "./graph-type"; + +/** + * Une interface pour nourrir un ResultsGraphComponent + */ +export interface PlottableData { + + graphType: GraphType; + chartX: string; + chartY: string; + + /** + * Returns the label to display, for an element of getAvailableChartAxis() + * (usually a variable symbol like "Q", "Z1"…) + * @param symbol parameter / result symbol (ex: "Q") + */ + getChartAxisLabel(symbol: string); + + /** + * Returns a list of plottable parameters / result elements, that can be defined + * as X or Y chart axis + */ + getAvailableChartAxis(): string[]; + + /** + * Returns the series of values for the required variated parameter / result element + * @param symbol parameter / result symbol (ex: "Q") + */ + getValuesSeries(symbol: string): any[]; +} diff --git a/src/app/results/plottable-pab-results.ts b/src/app/results/plottable-pab-results.ts new file mode 100644 index 000000000..9038608dd --- /dev/null +++ b/src/app/results/plottable-pab-results.ts @@ -0,0 +1,193 @@ +import { PlottableData } from "./plottable-data"; +import { PabResults } from "./pab-results"; +import { GraphType } from "./graph-type"; +import { ServiceFactory } from "../services/service-factory"; + +export class PlottablePabResults implements PlottableData { + + public graphType: GraphType = GraphType.Scatter; + public chartX: string; + public chartY: string; + + protected pabResults: PabResults; + + public constructor(pabResults: PabResults) { + this.pabResults = pabResults; + + // axes par défaut + console.log(">> axes par défaut"); + this.chartX = "CLOISON"; + this.chartY = "Z1_PAB"; + } + + /** + * Returns the label to display, for an element of getAvailableChartAxis() + * @param symbol parameter / result symbol (ex: "Q") + */ + public getChartAxisLabel(symbol: string) { + return this.pabResults.headers[this.pabResults.columns.indexOf(symbol)]; + } + + /** + * Returns a list of plottable parameters / result elements, that can be defined + * as X or Y chart axis + */ + public getAvailableChartAxis(): string[] { + return this.pabResults.columns; + } + + /** + * Returns the series of values for the required symbol + * @param symbol parameter / result symbol (ex: "Q") + */ + public getValuesSeries(symbol: string): any[] { + const data: string[] = []; + const pr = this.pabResults; + const nDigits = ServiceFactory.instance.applicationSetupService.displayDigits; + const l = this.pabResults.cloisonsResults.length; + + switch (symbol) { + case "CLOISON": + data.push(""); + for (let i = 0; i < l; i++) { + data.push("" + (i + 1)); + } + data.push(ServiceFactory.instance.i18nService.localizeText("INFO_EXTRARES_LIB_AVAL")); + break; + + case "DH": + data.push(""); + for (let i = 0; i < l - 1; i++) { + data.push((pr.cloisonsResults[i].vCalc - pr.cloisonsResults[i + 1].vCalc).toFixed(nDigits)); + } + data.push((pr.cloisonsResults[l - 1].vCalc - pr.cloisonAvalResults.vCalc).toFixed(nDigits)); + data.push((pr.cloisonAvalResults.vCalc - pr.Z2).toFixed(nDigits)); + break; + + case "ZR": + data.push(""); + for (let i = 0; i < l; i++) { + const er = pr.cloisonsResults[i].getExtraResult("ZRAM"); + data.push((er !== undefined) ? er.toFixed(nDigits) : ""); + } + const zrAval = pr.cloisonAvalResults.getExtraResult("ZRAM"); + data.push((zrAval !== undefined) ? zrAval.toFixed(nDigits) : ""); + break; + + case "Q": + data.push(""); + for (let i = 0; i < l; i++) { + data.push(pr.cloisonsQ[i].toFixed(nDigits)); + } + data.push(pr.cloisonAvalQ.toFixed(nDigits)); + break; + + case "Z1_PAB": + for (let i = 0; i < l - 1; i++) { + data.push(pr.cloisonsResults[i].vCalc.toFixed(nDigits)); + } + data.push(pr.cloisonAvalResults.vCalc.toFixed(nDigits)); + data.push(pr.Z2.toFixed(nDigits)); + break; + + case "PV": + data.push(""); + for (let i = 0; i < l; i++) { + const er = pr.cloisonsResults[i].getExtraResult("PV"); + data.push((er !== undefined) ? er.toFixed(nDigits) : ""); + } + data.push(""); + break; + + case "TMOY": + data.push(""); + for (let i = 0; i < l; i++) { + const er = pr.cloisonsResults[i].getExtraResult("Y"); + data.push((er !== undefined) ? er.toFixed(nDigits) : ""); + } + data.push(""); + break; + + case "ZRB": + data.push(""); + for (let i = 0; i < l; i++) { + const er = pr.cloisonsResults[i].getExtraResult("ZRB"); + data.push((er !== undefined) ? er.toFixed(nDigits) : ""); + } + data.push(""); + break; + + case "QA": + data.push(""); + for (let i = 0; i < l; i++) { + data.push(pr.bassinsQA[i].toFixed(nDigits)); + } + data.push(""); + break; + } + + // line 1 + /* this._dataSet.push([ + "", "", "", "", + this._pabResults.cloisonsResults[0] ? this._pabResults.cloisonsResults[0].vCalc.toFixed(nDigits) : "X", + "", "", "", "" + ]); + + // lines 2 - n-1 + for (let i = 0; i < pr.cloisonsResults.length - 1; i++) { + // console.log("pr.cloisonsResults[i]", pr.cloisonsResults[i]); + // console.log("resultElement STRINGIFIÉ", JSON.stringify(pr.cloisonsResults[i].resultElement)); + const ZRAM = pr.cloisonsResults[i].getExtraResult("ZRAM"); + const PV = pr.cloisonsResults[i].getExtraResult("PV"); + const Y = pr.cloisonsResults[i].getExtraResult("Y"); + const ZRB = pr.cloisonsResults[i].getExtraResult("ZRB"); + this._dataSet.push([ + i + 1, + (pr.cloisonsResults[i].vCalc - pr.cloisonsResults[i + 1].vCalc).toFixed(nDigits), + (ZRAM !== undefined) ? ZRAM.toFixed(nDigits) : "X", + pr.cloisonsQ[i].toFixed(nDigits), + pr.cloisonsResults[i + 1].vCalc.toFixed(nDigits), + (PV !== undefined) ? PV.toFixed(nDigits) : "X", + (Y !== undefined) ? Y.toFixed(nDigits) : "X", + (ZRB !== undefined) ? ZRB.toFixed(nDigits) : "X", + pr.bassinsQA[i] + ]); + } + + // line n + const l = pr.cloisonsResults.length; + const nZRAM = pr.cloisonsResults[l - 1].getExtraResult("ZRAM"); + const nPV = pr.cloisonsResults[l - 1].getExtraResult("PV"); + const nY = pr.cloisonsResults[l - 1].getExtraResult("Y"); + const nZRB = pr.cloisonsResults[l - 1].getExtraResult("ZRB"); + this._dataSet.push([ + l, + (pr.cloisonsResults[l - 1].vCalc - pr.cloisonAvalResults.vCalc).toFixed(nDigits), + (nZRAM !== undefined) ? nZRAM.toFixed(nDigits) : "X", + pr.cloisonsQ[l - 1].toFixed(nDigits), + pr.cloisonAvalResults.vCalc.toFixed(nDigits), + (nPV !== undefined) ? nPV.toFixed(nDigits) : "X", + (nY !== undefined) ? nY.toFixed(nDigits) : "X", + (nZRB !== undefined) ? nZRB.toFixed(nDigits) : "X", + pr.bassinsQA[l - 1] + ]); + + // downstream line + const caZRAM = pr.cloisonAvalResults.getExtraResult("ZRAM"); + this._dataSet.push([ + this.intlService.localizeText("INFO_EXTRARES_LIB_AVAL"), + (pr.cloisonAvalResults.vCalc - pr.Z2).toFixed(nDigits), + (caZRAM !== undefined) ? caZRAM.toFixed(nDigits) : "X", + pr.cloisonAvalQ.toFixed(nDigits), + pr.Z2.toFixed(nDigits), + "", + "", + "", + "" + ]); */ + + + + return data; + } +} diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts index da0be9d5f..8224154f1 100644 --- a/src/app/results/var-results.ts +++ b/src/app/results/var-results.ts @@ -3,29 +3,10 @@ import { CalculatedParamResults } from "./param-calc-results"; import { NgParameter } from "../formulaire/ngparam"; import { ResultElement } from "jalhyd"; import { ServiceFactory } from "../services/service-factory"; +import { PlottableData } from "./plottable-data"; +import { GraphType } from "./graph-type"; -/** - * type de graphe - */ -export enum GraphType { - /** - * histogramme - */ - Histogram, - - /** - * points indépendants reliés par une courbe - */ - HistoLine, - - /** - * graphe XY classique - */ - Scatter, -} - - -export class VarResults extends CalculatedParamResults { +export class VarResults extends CalculatedParamResults implements PlottableData { /** * paramètre varié */ @@ -103,6 +84,20 @@ export class VarResults extends CalculatedParamResults { return this._extraResultHeaders; } + public getChartAxisLabel(symbol: string) { + // 1. calculated param ? + if (this.calculatedParameter && this.calculatedParameter.symbol === symbol) { + return this.calculatedParameterHeader; + } else + // 2. variated param ? + if (this.variatedParameter.symbol === symbol) { + return this.variableParamHeader; + } else { + // 3. Result element ? + return ServiceFactory.instance.i18nService.getExtraResLabel(symbol); + } + } + /** * Returns the series of values for the required variated parameter / result element * @param symbol parameter / result symbol (ex: "Q") @@ -139,7 +134,6 @@ export class VarResults extends CalculatedParamResults { /** * Returns a list of plottable parameters / result elements, that can be defined * as X or Y chart axis - * @param except exclude this symbol from the list */ public getAvailableChartAxis(): string[] { const res: string[] = []; -- GitLab