Commit 83a4732e authored by Mathias Chouet's avatar Mathias Chouet :spaghetti:
Browse files

Axes des graphiques: nom complet avec unité

Showing with 41 additions and 9 deletions
+41 -9
...@@ -104,7 +104,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont ...@@ -104,7 +104,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
/** /**
* Returns a human readable description of any param / result symbol * Returns a human readable description of any param / result symbol
*/ */
public getChartAxisLabel(symbol: string) { public getChartAxisLabel(symbol: string): string {
return this._results.getChartAxisLabel(symbol); return this._results.getChartAxisLabel(symbol);
} }
...@@ -135,6 +135,19 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont ...@@ -135,6 +135,19 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
this._graphTypeComponent.addObserver(this); 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 */ /** forces Angular to rebuild the chart @see bug #137 */
private forceRebuild() { private forceRebuild() {
this.displayChart = false; this.displayChart = false;
...@@ -172,13 +185,13 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont ...@@ -172,13 +185,13 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
}, },
scaleLabel: { scaleLabel: {
display: true, display: true,
labelString: this.chartX labelString: this.axisLabelWithoutSymbol(this.chartX)
} }
}], }],
yAxes: [{ yAxes: [{
scaleLabel: { scaleLabel: {
display: true, display: true,
labelString: this.chartY labelString: this.axisLabelWithoutSymbol(this.chartY)
} }
}] }]
}; };
...@@ -224,7 +237,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont ...@@ -224,7 +237,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
}, },
scaleLabel: { scaleLabel: {
display: true, display: true,
labelString: this.chartX labelString: this.axisLabelWithoutSymbol(this.chartX)
} }
}], }],
yAxes: [{ yAxes: [{
...@@ -235,7 +248,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont ...@@ -235,7 +248,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont
}, },
scaleLabel: { scaleLabel: {
display: true, display: true,
labelString: this.chartY labelString: this.axisLabelWithoutSymbol(this.chartY)
} }
}] }]
}; };
......
...@@ -14,7 +14,13 @@ export interface PlottableData { ...@@ -14,7 +14,13 @@ export interface PlottableData {
* (usually a variable symbol like "Q", "Z1"…) * (usually a variable symbol like "Q", "Z1"…)
* @param symbol parameter / result symbol (ex: "Q") * @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 * Returns a list of plottable parameters / result elements, that can be defined
......
...@@ -29,10 +29,14 @@ export class PlottablePabResults implements PlottableData { ...@@ -29,10 +29,14 @@ export class PlottablePabResults implements PlottableData {
* Returns the label to display, for an element of getAvailableChartAxis() * Returns the label to display, for an element of getAvailableChartAxis()
* @param symbol parameter / result symbol (ex: "Q") * @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)]; 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 * Returns a list of plottable parameters / result elements, that can be defined
* as X or Y chart axis * as X or Y chart axis
......
...@@ -93,7 +93,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData ...@@ -93,7 +93,7 @@ export class VarResults extends CalculatedParamResults implements PlottableData
return this._extraResultHeaders; return this._extraResultHeaders;
} }
public getChartAxisLabel(symbol: 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) {
return this.calculatedParameterHeader; return this.calculatedParameterHeader;
...@@ -104,7 +104,16 @@ export class VarResults extends CalculatedParamResults implements PlottableData ...@@ -104,7 +104,16 @@ export class VarResults extends CalculatedParamResults implements PlottableData
return this.variableParamHeaders[i]; 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 // calculator type for translation
const sn = this.result.sourceNub; const sn = this.result.sourceNub;
let ct = sn.calcType; let ct = sn.calcType;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment