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

#234 : ajout de la légende

parent d4a842c6
No related branches found
No related tags found
1 merge request!49Resolve "Ajout du module de calcul d'une passe à bassins"
......@@ -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
*/
......
......@@ -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",
......
......@@ -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",
......
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