diff --git a/src/app/components/results-graph/results-graph.component.ts b/src/app/components/results-graph/results-graph.component.ts index 9cc50d8e774bf23f08d8737ae64f90d29bf19de7..5cc0a4590950a287b9b2d5a42131b4523f1322dc 100644 --- a/src/app/components/results-graph/results-graph.component.ts +++ b/src/app/components/results-graph/results-graph.component.ts @@ -195,10 +195,26 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont } }] }; + const that = this; this.graph_options["tooltips"] = { + displayColors: false, callbacks: { - label: function(tooltipItem, data) { - return Number(tooltipItem.yLabel).toFixed(nDigits); + title: (tooltipItems, data) => { + return this.chartY + " = " + Number(tooltipItems[0].yLabel).toFixed(nDigits); + }, + label: (tooltipItem, data) => { + const lines: string[] = []; + for (const v of that._results.getVariatingParametersSymbols()) { + const series = that._results.getValuesSeries(v); + const line = v + " = " + series[tooltipItem.index].toFixed(nDigits); + if (v === this.chartX) { + lines.unshift(""); + lines.unshift(line); + } else { + lines.push(line); + } + } + return lines; } } }; @@ -252,10 +268,26 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont } }] }; + const that = this; this.graph_options["tooltips"] = { + displayColors: false, callbacks: { - label: function(tooltipItem, data) { - return "(" + Number(tooltipItem.xLabel).toFixed(nDigits) + ", " + Number(tooltipItem.yLabel).toFixed(nDigits) + ")"; + title: (tooltipItems, data) => { + return this.chartY + " = " + Number(tooltipItems[0].yLabel).toFixed(nDigits); + }, + label: (tooltipItem, data) => { + const lines: string[] = []; + for (const v of that._results.getVariatingParametersSymbols()) { + const series = that._results.getValuesSeries(v); + const line = v + " = " + series[tooltipItem.index].toFixed(nDigits); + if (v === this.chartX) { + lines.unshift(""); + lines.unshift(line); + } else { + lines.push(line); + } + } + return lines; } } }; diff --git a/src/app/results/plottable-data.ts b/src/app/results/plottable-data.ts index d750529b72cc64fb28ebce31a95890378348d58f..a5493b94be96bd509ec89ad9c9a61facd54ffa9c 100644 --- a/src/app/results/plottable-data.ts +++ b/src/app/results/plottable-data.ts @@ -33,4 +33,10 @@ export interface PlottableData { * @param symbol parameter / result symbol (ex: "Q") */ getValuesSeries(symbol: string): any[]; + + /** + * Returns the list of variating parameters + * (used by tooltip functions) + */ + getVariatingParametersSymbols(): string[]; } diff --git a/src/app/results/plottable-pab-results.ts b/src/app/results/plottable-pab-results.ts index b8bfe90c9582da50d48f8b4d33a2f5cf893f35a2..27e5685d9d0c257798729acf56326acf3c22d1dc 100644 --- a/src/app/results/plottable-pab-results.ts +++ b/src/app/results/plottable-pab-results.ts @@ -45,6 +45,11 @@ export class PlottablePabResults implements PlottableData { return this.pabResults.columns; } + // just to implement interface + public getVariatingParametersSymbols(): string[] { + return []; + } + /** * Returns the series of values for the required symbol * @param symbol parameter / result symbol (ex: "Q") diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts index 95898befc6ed44d44f72e6e9ac013e316b0c7bad..b01195b15a1cd932d5b18b4fdf6d8ae9cd9fd795 100644 --- a/src/app/results/var-results.ts +++ b/src/app/results/var-results.ts @@ -176,6 +176,16 @@ export class VarResults extends CalculatedParamResults implements PlottableData return res; } + /** + * Returns the list of variating parameters + * (used by tooltip functions) + */ + public getVariatingParametersSymbols(): string[] { + return this._variatedParams.map((vp) => { + return vp.symbol; + }); + } + public update(displaySymbol: boolean) { if (this._variableParamHeaders.length === 0) { this._variableParamHeaders = this._variatedParams.map((v) => {