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

Axes des graphiques: nom complet avec unité

parent e1ba75a4
No related branches found
No related tags found
1 merge request!46Resolve "Fonctionnalité : plusieurs paramètres qui varient (Voir Jalhyd#62)"
......@@ -104,7 +104,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
/**
* Returns a human readable description of any param / result symbol
*/
public getChartAxisLabel(symbol: string) {
public getChartAxisLabel(symbol: string): string {
return this._results.getChartAxisLabel(symbol);
}
......@@ -135,6 +135,19 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
this._graphTypeComponent.addObserver(this);
}
/**
* Calls getChartAxisLabel() and removes the symbol prefix
* (cannot rebuild a clean label here)
*/
private axisLabelWithoutSymbol(symbol: string) {
let l = this._results.getChartAxisLabel(symbol);
const i = l.indexOf(": ");
if (i !== -1) {
l = l.substring(i + 2);
}
return l;
}
/** forces Angular to rebuild the chart @see bug #137 */
private forceRebuild() {
this.displayChart = false;
......@@ -172,13 +185,13 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
},
scaleLabel: {
display: true,
labelString: this.chartX
labelString: this.axisLabelWithoutSymbol(this.chartX)
}
}],
yAxes: [{
scaleLabel: {
display: true,
labelString: this.chartY
labelString: this.axisLabelWithoutSymbol(this.chartY)
}
}]
};
......@@ -224,7 +237,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
},
scaleLabel: {
display: true,
labelString: this.chartX
labelString: this.axisLabelWithoutSymbol(this.chartX)
}
}],
yAxes: [{
......@@ -235,7 +248,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
},
scaleLabel: {
display: true,
labelString: this.chartY
labelString: this.axisLabelWithoutSymbol(this.chartY)
}
}]
};
......
......@@ -14,7 +14,13 @@ export interface PlottableData {
* (usually a variable symbol like "Q", "Z1"…)
* @param symbol parameter / result symbol (ex: "Q")
*/
getChartAxisLabel(symbol: string);
getChartAxisLabel(symbol: string): string;
/**
* Returns the translated name of the given symbol (usually an extraResult)
* if available, with its unit, but without the symbol itself
*/
expandLabelFromSymbol(symbol: string): string;
/**
* Returns a list of plottable parameters / result elements, that can be defined
......
......@@ -29,10 +29,14 @@ export class PlottablePabResults implements PlottableData {
* Returns the label to display, for an element of getAvailableChartAxis()
* @param symbol parameter / result symbol (ex: "Q")
*/
public getChartAxisLabel(symbol: string) {
public getChartAxisLabel(symbol: string): string {
return this.pabResults.headers[this.pabResults.columns.indexOf(symbol)];
}
public expandLabelFromSymbol(symbol: string): string {
return symbol;
}
/**
* Returns a list of plottable parameters / result elements, that can be defined
* as X or Y chart axis
......
......@@ -93,7 +93,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData
return this._extraResultHeaders;
}
public getChartAxisLabel(symbol: string) {
public getChartAxisLabel(symbol: string): string {
// 1. calculated param ?
if (this.calculatedParameter && this.calculatedParameter.symbol === symbol) {
return this.calculatedParameterHeader;
......@@ -104,7 +104,16 @@ export class VarResults extends CalculatedParamResults implements PlottableData
return this.variableParamHeaders[i];
}
}
// 3. Result element ?
// 3. Result element
return this.expandLabelFromSymbol(symbol);
}
/**
* Returns the translated name of the given symbol (usually an extraResult) with
* its unit, but without the symbol itself
*/
public expandLabelFromSymbol(symbol: string): string {
// calculator type for translation
const sn = this.result.sourceNub;
let ct = sn.calcType;
......
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