Skip to content
Snippets Groups Projects
Commit 68582dbb authored by mathias.chouet's avatar mathias.chouet
Browse files

Work on #246

parent 314768c3
No related branches found
No related tags found
1 merge request!54Resolve "ParallelStructure : tracer sur le graphique une série par ouvrage, afin de les comparer"
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
<div class="select-x-y-axis" fxLayout="row wrap" fxLayoutAlign="space-between start"> <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-form-field fxFlex.gt-xs="1 0 auto" fxFlex.lt-sm="1 0 100%">
<mat-select id="selectX" [placeholder]="uitextSelectX" [(value)]="chartX"> <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) }} {{ getChartAxisLabel(x) }}
</mat-option> </mat-option>
</mat-select> </mat-select>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<mat-form-field fxFlex.gt-xs="1 0 auto" fxFlex.lt-sm="1 0 100%"> <mat-form-field fxFlex.gt-xs="1 0 auto" fxFlex.lt-sm="1 0 100%">
<mat-select id="selectY" [placeholder]="uitextSelectY" [(value)]="chartY"> <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) }} {{ getChartAxisLabel(y) }}
</mat-option> </mat-option>
</mat-select> </mat-select>
......
...@@ -96,9 +96,20 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont ...@@ -96,9 +96,20 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
} }
} }
public get availableChartAxis() { public get availableXAxis() {
if (this._results) { 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();
}
} }
} }
......
...@@ -54,7 +54,7 @@ export class FormComputeFixedVar extends FormCompute { ...@@ -54,7 +54,7 @@ export class FormComputeFixedVar extends FormCompute {
this.formResult.varResults.calculatedParameter = computedParam; this.formResult.varResults.calculatedParameter = computedParam;
this.formResult.varResults.result = nub.result; this.formResult.varResults.result = nub.result;
this.formResult.varResults.update(false); this.formResult.varResults.update();
} }
} }
} }
...@@ -44,7 +44,7 @@ export class FormComputeSectionParametree extends FormCompute { ...@@ -44,7 +44,7 @@ export class FormComputeSectionParametree extends FormCompute {
// résultats variés avec tous les résultats complémentaires // résultats variés avec tous les résultats complémentaires
this._varResults.variatedParameters = varParams; this._varResults.variatedParameters = varParams;
this._varResults.result = sectNub.result; this._varResults.result = sectNub.result;
this._varResults.update(false); this._varResults.update();
} else { } else {
// résultats de section (avec le graphique de section) // résultats de section (avec le graphique de section)
this._sectionResults.result = sectNub.result; this._sectionResults.result = sectNub.result;
......
...@@ -24,9 +24,15 @@ export interface PlottableData { ...@@ -24,9 +24,15 @@ export interface PlottableData {
/** /**
* Returns a list of plottable parameters / result elements, that can be defined * 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 * Returns the series of values for the required variated parameter / result element
......
...@@ -50,6 +50,14 @@ export class PlottablePabResults implements PlottableData { ...@@ -50,6 +50,14 @@ export class PlottablePabResults implements PlottableData {
return [ "x" ].concat(this.pabResults.columns); return [ "x" ].concat(this.pabResults.columns);
} }
public getAvailableXAxis(): string[] {
return this.getAvailableChartAxis();
}
public getAvailableYAxis(): string[] {
return this.getAvailableChartAxis();
}
// just to implement interface // just to implement interface
public getVariatingParametersSymbols(): string[] { public getVariatingParametersSymbols(): string[] {
return []; return [];
......
...@@ -152,7 +152,7 @@ export class RemousResults extends CalculatorResults { ...@@ -152,7 +152,7 @@ export class RemousResults extends CalculatorResults {
keys.push(this.extraParamSymbol); keys.push(this.extraParamSymbol);
} }
this._varResults.extraResultKeys = keys; this._varResults.extraResultKeys = keys;
this._varResults.update(true); this._varResults.update();
} }
public get extraParamSymbol(): string { public get extraParamSymbol(): string {
......
import { CalculatorResults } from "./calculator-results"; import { CalculatorResults } from "./calculator-results";
import { CalculatedParamResults } from "./param-calc-results"; import { CalculatedParamResults } from "./param-calc-results";
import { NgParameter } from "../formulaire/ngparam"; import { NgParameter } from "../formulaire/ngparam";
import { ResultElement } from "jalhyd"; import { ResultElement, ParamFamily } from "jalhyd";
import { ServiceFactory } from "../services/service-factory"; import { ServiceFactory } from "../services/service-factory";
import { PlottableData } from "./plottable-data"; import { PlottableData } from "./plottable-data";
import { GraphType } from "./graph-type"; import { GraphType } from "./graph-type";
...@@ -30,7 +30,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData ...@@ -30,7 +30,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData
/** /**
* type de graphe * type de graphe
*/ */
public graphType: GraphType = GraphType.Scatter; protected _graphType: GraphType = GraphType.Scatter;
/** /**
* variated parameter or result displayed as chart's X-axis * variated parameter or result displayed as chart's X-axis
...@@ -93,6 +93,15 @@ export class VarResults extends CalculatedParamResults implements PlottableData ...@@ -93,6 +93,15 @@ export class VarResults extends CalculatedParamResults implements PlottableData
return this._extraResultHeaders; 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 { public getChartAxisLabel(symbol: string): string {
// 1. calculated param ? // 1. calculated param ?
if (this.calculatedParameter && this.calculatedParameter.symbol === symbol) { if (this.calculatedParameter && this.calculatedParameter.symbol === symbol) {
...@@ -160,9 +169,9 @@ export class VarResults extends CalculatedParamResults implements PlottableData ...@@ -160,9 +169,9 @@ export class VarResults extends CalculatedParamResults implements PlottableData
/** /**
* Returns a list of plottable parameters / result elements, that can be defined * 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[] = []; const res: string[] = [];
if (this.calculatedParameter) { if (this.calculatedParameter) {
res.push(this.calculatedParameter.symbol); res.push(this.calculatedParameter.symbol);
...@@ -176,6 +185,71 @@ export class VarResults extends CalculatedParamResults implements PlottableData ...@@ -176,6 +185,71 @@ export class VarResults extends CalculatedParamResults implements PlottableData
return res; 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 * Returns the list of variating parameters
* (used by tooltip functions) * (used by tooltip functions)
...@@ -186,7 +260,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData ...@@ -186,7 +260,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData
}); });
} }
public update(displaySymbol: boolean) { public update() {
if (this._variableParamHeaders.length === 0) { if (this._variableParamHeaders.length === 0) {
this._variableParamHeaders = this._variatedParams.map((v) => { this._variableParamHeaders = this._variatedParams.map((v) => {
return CalculatorResults.paramLabel(v, true); return CalculatorResults.paramLabel(v, true);
...@@ -244,14 +318,18 @@ export class VarResults extends CalculatedParamResults implements PlottableData ...@@ -244,14 +318,18 @@ export class VarResults extends CalculatedParamResults implements PlottableData
ServiceFactory.instance.formulaireService.expandVariableNameAndUnit(ct, k) 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) * When variable parameter or graph type changes, ensure the X / Y current values are still available
const aca = this.getAvailableChartAxis(); */
if (! aca.includes(this.chartX)) { public resetDefaultAxisIfNeeded() {
console.log("RDAIN");
if (! this.getAvailableXAxis().includes(this.chartX)) {
this.chartX = this.variatedParameters[0].symbol; this.chartX = this.variatedParameters[0].symbol;
} }
if (! aca.includes(this.chartY)) { if (! this.getAvailableYAxis().includes(this.chartY)) {
this.chartY = this.variatedParameters[0].symbol; this.chartY = this.variatedParameters[0].symbol;
} }
} }
......
...@@ -135,6 +135,16 @@ ...@@ -135,6 +135,16 @@
"INFO_WALL_REMOVED": "Wall #%s removed", "INFO_WALL_REMOVED": "Wall #%s removed",
"INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.",
"INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", "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_ABSCISSE_CLOISON": "Wall abscissa",
"INFO_LIB_ALPHA": "Alpha coefficient", "INFO_LIB_ALPHA": "Alpha coefficient",
"INFO_LIB_ALPHA2": "Half-angle at the apex", "INFO_LIB_ALPHA2": "Half-angle at the apex",
......
...@@ -135,6 +135,16 @@ ...@@ -135,6 +135,16 @@
"INFO_WALL_REMOVED": "Cloison n°%s supprimée", "INFO_WALL_REMOVED": "Cloison n°%s supprimée",
"INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.", "INFO_LECHAPTCALMON_TITRE_COURT": "Lechapt-C.",
"INFO_LECHAPTCALMON_TITRE": "Lechapt-Calmon", "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_ABSCISSE_CLOISON": "Abscisse de la cloison",
"INFO_LIB_ALPHA": "Coefficient alpha", "INFO_LIB_ALPHA": "Coefficient alpha",
"INFO_LIB_ALPHA2": "Demi-angle au sommet", "INFO_LIB_ALPHA2": "Demi-angle au sommet",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment