diff --git a/src/app/components/results-graph/results-graph.component.ts b/src/app/components/results-graph/results-graph.component.ts index efd02528851648f261c58ec55f4d9b3112257253..9cc50d8e774bf23f08d8737ae64f90d29bf19de7 100644 --- a/src/app/components/results-graph/results-graph.component.ts +++ b/src/app/components/results-graph/results-graph.component.ts @@ -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) } }] }; diff --git a/src/app/results/plottable-data.ts b/src/app/results/plottable-data.ts index 609c388aaaa0cb49556063ce170c88478cec7c26..d750529b72cc64fb28ebce31a95890378348d58f 100644 --- a/src/app/results/plottable-data.ts +++ b/src/app/results/plottable-data.ts @@ -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 diff --git a/src/app/results/plottable-pab-results.ts b/src/app/results/plottable-pab-results.ts index c8cdd29641aa9801f8394052f6d888f00bf2dcd7..b8bfe90c9582da50d48f8b4d33a2f5cf893f35a2 100644 --- a/src/app/results/plottable-pab-results.ts +++ b/src/app/results/plottable-pab-results.ts @@ -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 diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts index 4f7fcf28a6a2b266a73797d91c54e4eeed3f16bb..95898befc6ed44d44f72e6e9ac013e316b0c7bad 100644 --- a/src/app/results/var-results.ts +++ b/src/app/results/var-results.ts @@ -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;