diff --git a/src/app/components/results-graph/results-graph.component.html b/src/app/components/results-graph/results-graph.component.html index 50024d806d5cfa794c3279ef6cc0fe975acea5a1..d27357a5e101741950d26cdde8409611d6e989a1 100644 --- a/src/app/components/results-graph/results-graph.component.html +++ b/src/app/components/results-graph/results-graph.component.html @@ -26,7 +26,7 @@ <div class="select-x-y-axis" fxLayout="row wrap" fxLayoutAlign="space-between start"> <mat-form-field fxFlex.gt-xs="1 0 auto" fxFlex.lt-sm="1 0 100%"> <mat-select id="selectX" [placeholder]="uitextSelectX" [(value)]="chartX"> - <mat-option *ngFor="let x of availableChartAxis" [value]="x" [title]="getChartAxisLabel(x)"> + <mat-option *ngFor="let x of availableXAxis" [value]="x" [title]="getChartAxisLabel(x)"> {{ getChartAxisLabel(x) }} </mat-option> </mat-select> @@ -36,7 +36,7 @@ <mat-form-field fxFlex.gt-xs="1 0 auto" fxFlex.lt-sm="1 0 100%"> <mat-select id="selectY" [placeholder]="uitextSelectY" [(value)]="chartY"> - <mat-option *ngFor="let y of availableChartAxis" [value]="y" [title]="getChartAxisLabel(y)"> + <mat-option *ngFor="let y of availableYAxis" [value]="y" [title]="getChartAxisLabel(y)"> {{ getChartAxisLabel(y) }} </mat-option> </mat-select> diff --git a/src/app/components/results-graph/results-graph.component.ts b/src/app/components/results-graph/results-graph.component.ts index 6ea796e94b9161eac14c5bc545e51089afc5ab8d..07f5703a8a500f3c9da62e312237c7ee752fb7ab 100644 --- a/src/app/components/results-graph/results-graph.component.ts +++ b/src/app/components/results-graph/results-graph.component.ts @@ -96,9 +96,20 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont } } - public get availableChartAxis() { + public get availableXAxis() { if (this._results) { - return this._results.getAvailableChartAxis(); + return this._results.getAvailableXAxis(); + } + } + + public get availableYAxis() { + if (this._results) { + if (this._results.graphType !== GraphType.Scatter) { + // do not use real Y axis (that include families), if chart cannot display multiple series + return this._results.getAvailableXAxis(); + } else { + return this._results.getAvailableYAxis(); + } } } diff --git a/src/app/formulaire/definition/form-compute-fixedvar.ts b/src/app/formulaire/definition/form-compute-fixedvar.ts index 2900c66b1b2f49a2c5674fc4af906ca92583befa..00d5793b3e0b26a34340904c1e2e504c371b8b3e 100644 --- a/src/app/formulaire/definition/form-compute-fixedvar.ts +++ b/src/app/formulaire/definition/form-compute-fixedvar.ts @@ -54,7 +54,7 @@ export class FormComputeFixedVar extends FormCompute { this.formResult.varResults.calculatedParameter = computedParam; this.formResult.varResults.result = nub.result; - this.formResult.varResults.update(false); + this.formResult.varResults.update(); } } } diff --git a/src/app/formulaire/definition/form-compute-section-parametree.ts b/src/app/formulaire/definition/form-compute-section-parametree.ts index 3e833eed46eeac7a0a991bafde36403d373036b9..a1380b6588b7852a912e471b31d0d375cc4aaa39 100644 --- a/src/app/formulaire/definition/form-compute-section-parametree.ts +++ b/src/app/formulaire/definition/form-compute-section-parametree.ts @@ -44,7 +44,7 @@ export class FormComputeSectionParametree extends FormCompute { // résultats variés avec tous les résultats complémentaires this._varResults.variatedParameters = varParams; this._varResults.result = sectNub.result; - this._varResults.update(false); + this._varResults.update(); } else { // résultats de section (avec le graphique de section) this._sectionResults.result = sectNub.result; diff --git a/src/app/results/plottable-data.ts b/src/app/results/plottable-data.ts index a5493b94be96bd509ec89ad9c9a61facd54ffa9c..687c4027353912d2a8c0ef4ca286e17db5ec8615 100644 --- a/src/app/results/plottable-data.ts +++ b/src/app/results/plottable-data.ts @@ -24,9 +24,15 @@ export interface PlottableData { /** * Returns a list of plottable parameters / result elements, that can be defined - * as X or Y chart axis + * as X chart axis */ - getAvailableChartAxis(): string[]; + getAvailableXAxis(): string[]; + + /** + * Returns a list of plottable parameters / result elements / families, + * that can be defined as Y chart axis + */ + getAvailableYAxis(): string[]; /** * Returns the series of values for the required variated parameter / result element diff --git a/src/app/results/plottable-pab-results.ts b/src/app/results/plottable-pab-results.ts index 57a4dd318b9c815ad3f36d5c65959ea61c78c7d8..c75e3f5b31e87448ace4067bd7eef3f92fba5908 100644 --- a/src/app/results/plottable-pab-results.ts +++ b/src/app/results/plottable-pab-results.ts @@ -50,6 +50,14 @@ export class PlottablePabResults implements PlottableData { return [ "x" ].concat(this.pabResults.columns); } + public getAvailableXAxis(): string[] { + return this.getAvailableChartAxis(); + } + + public getAvailableYAxis(): string[] { + return this.getAvailableChartAxis(); + } + // just to implement interface public getVariatingParametersSymbols(): string[] { return []; diff --git a/src/app/results/remous-results.ts b/src/app/results/remous-results.ts index 6d6e1f6e104badd016b4c449f01127e889ee05f0..5610468f5ae7afddb822d669876b77b3dfdd4492 100644 --- a/src/app/results/remous-results.ts +++ b/src/app/results/remous-results.ts @@ -152,7 +152,7 @@ export class RemousResults extends CalculatorResults { keys.push(this.extraParamSymbol); } this._varResults.extraResultKeys = keys; - this._varResults.update(true); + this._varResults.update(); } public get extraParamSymbol(): string { diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts index b01195b15a1cd932d5b18b4fdf6d8ae9cd9fd795..0b43f067b6df55bb834b3b60b0119d07e7737b10 100644 --- a/src/app/results/var-results.ts +++ b/src/app/results/var-results.ts @@ -1,7 +1,7 @@ import { CalculatorResults } from "./calculator-results"; import { CalculatedParamResults } from "./param-calc-results"; import { NgParameter } from "../formulaire/ngparam"; -import { ResultElement } from "jalhyd"; +import { ResultElement, ParamFamily } from "jalhyd"; import { ServiceFactory } from "../services/service-factory"; import { PlottableData } from "./plottable-data"; import { GraphType } from "./graph-type"; @@ -30,7 +30,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData /** * type de graphe */ - public graphType: GraphType = GraphType.Scatter; + protected _graphType: GraphType = GraphType.Scatter; /** * variated parameter or result displayed as chart's X-axis @@ -93,6 +93,15 @@ export class VarResults extends CalculatedParamResults implements PlottableData return this._extraResultHeaders; } + public get graphType(): GraphType { + return this._graphType; + } + + public set graphType(gt: GraphType) { + this._graphType = gt; + this.resetDefaultAxisIfNeeded(); + } + public getChartAxisLabel(symbol: string): string { // 1. calculated param ? if (this.calculatedParameter && this.calculatedParameter.symbol === symbol) { @@ -160,9 +169,9 @@ export class VarResults extends CalculatedParamResults implements PlottableData /** * Returns a list of plottable parameters / result elements, that can be defined - * as X or Y chart axis + * as X chart axis */ - public getAvailableChartAxis(): string[] { + public getAvailableXAxis(): string[] { const res: string[] = []; if (this.calculatedParameter) { res.push(this.calculatedParameter.symbol); @@ -176,6 +185,71 @@ export class VarResults extends CalculatedParamResults implements PlottableData return res; } + /** + * Same as X axis, plus results families if graph type is Scatter + * (for multi-series comparison) + */ + public getAvailableYAxis(): string[] { + const res: string[] = this.getAvailableXAxis(); + if (this._graphType === GraphType.Scatter) { + // add families having more than 1 variable as plottable ordinates + const families = this.extractFamilies(); + console.log("FOUND FAMILIES", families); + for (const f in families) { + if (families[f].length > 1) { + res.push(f); + } + } + } + return res; + } + + /** + * Browses all parameters and results to produce a map of families => list of + * symbols in this family + */ + private extractFamilies(): { [key: string]: string[] } { + const families: { [key: string]: string[] } = {}; + if (this.calculatedParameter) { + const f = ParamFamily[this.calculatedParameter.paramDefinition.family]; + console.log(`1 - calcParam: ${this.calculatedParameter.symbol} > ${f}`); + if (f !== undefined) { + if (! (f in families)) { + console.log("-- init to []"); + families[f] = []; + } + console.log("--- push", this.calculatedParameter.symbol); + families[f].push(this.calculatedParameter.symbol); + } + } + for (const v of this._variatedParams) { + const f = ParamFamily[v.paramDefinition.family]; + console.log(`2 - variatedParam: ${v.symbol} > ${f}`); + if (f !== undefined) { + if (! (f in families)) { + console.log("-- init to []"); + families[f] = []; + } + console.log("--- push", v.symbol); + families[f].push(v.symbol); + } + } + for (const erk in this.extraResultKeys) { + + const f = ParamFamily[this.result.sourceNub.extraResultsFamilies[erk]]; + console.log(`3 - extraResult: ${erk} > ${f}`); + if (f !== undefined) { + if (! (f in families)) { + console.log("-- init to []"); + families[f] = []; + } + console.log("--- push", erk); + families[f].push(erk); + } + } + return families; + } + /** * Returns the list of variating parameters * (used by tooltip functions) @@ -186,7 +260,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData }); } - public update(displaySymbol: boolean) { + public update() { if (this._variableParamHeaders.length === 0) { this._variableParamHeaders = this._variatedParams.map((v) => { return CalculatorResults.paramLabel(v, true); @@ -244,14 +318,18 @@ export class VarResults extends CalculatedParamResults implements PlottableData ServiceFactory.instance.formulaireService.expandVariableNameAndUnit(ct, k) ); } + this.resetDefaultAxisIfNeeded(); + } - // when variable parameter changes, ensure the X / Y current values are still available - // (might be the previous variated parameter, that is not accessible anymore) - const aca = this.getAvailableChartAxis(); - if (! aca.includes(this.chartX)) { + /** + * When variable parameter or graph type changes, ensure the X / Y current values are still available + */ + public resetDefaultAxisIfNeeded() { + console.log("RDAIN"); + if (! this.getAvailableXAxis().includes(this.chartX)) { this.chartX = this.variatedParameters[0].symbol; } - if (! aca.includes(this.chartY)) { + if (! this.getAvailableYAxis().includes(this.chartY)) { this.chartY = this.variatedParameters[0].symbol; } } diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 42c454e76a7660fe2fe527740e4eb2f9877817ba..03338726127252245ad8a21396eafc0d686f3e30 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -135,6 +135,16 @@ "INFO_WALL_REMOVED": "Wall #%s removed", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", + "INFO_LIB_LENGTHS": "Every length", + "INFO_LIB_WIDTHS": "Every width", + "INFO_LIB_SLOPES": "Every slope", + "INFO_LIB_HEIGHTS": "Every height", + "INFO_LIB_BASINFALLS": "Every basin fall", + "INFO_LIB_TOTALFALLS": "Every total fall", + "INFO_LIB_ELEVATIONS": "Every elevation", + "INFO_LIB_VOLUMES": "Every volume", + "INFO_LIB_FLOWS": "Every flow", + "INFO_LIB_DIAMETERS": "Every diameter", "INFO_LIB_ABSCISSE_CLOISON": "Wall abscissa", "INFO_LIB_ALPHA": "Alpha coefficient", "INFO_LIB_ALPHA2": "Half-angle at the apex", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 245c7a8208014c210291c5503482b46ec59705c7..9323382697d8374d982d28c441cc4bab0d48f2b5 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -135,6 +135,16 @@ "INFO_WALL_REMOVED": "Cloison n°%s supprimée", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", + "INFO_LIB_LENGTHS": "Toutes les longueurs", + "INFO_LIB_WIDTHS": "Toutes les largeurs", + "INFO_LIB_SLOPES": "Toutes les pentes", + "INFO_LIB_HEIGHTS": "Toutes les hauteurs", + "INFO_LIB_BASINFALLS": "Toutes les chutes entre bassins", + "INFO_LIB_TOTALFALLS": "Toutes les chutes totales", + "INFO_LIB_ELEVATIONS": "Toutes les cotes", + "INFO_LIB_VOLUMES": "Tous les volumes", + "INFO_LIB_FLOWS": "Tous les débits", + "INFO_LIB_DIAMETERS": "Tous les diamètres", "INFO_LIB_ABSCISSE_CLOISON": "Abscisse de la cloison", "INFO_LIB_ALPHA": "Coefficient alpha", "INFO_LIB_ALPHA2": "Demi-angle au sommet",