From 2cadfcac11efb57c34b9864bf689fc8e0b7bf650 Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Mon, 27 May 2019 15:34:01 +0200 Subject: [PATCH] =?UTF-8?q?Graphiques:=20am=C3=A9lioration=20des=20infobul?= =?UTF-8?q?les=20pour=20les=20param=C3=A8tres=20multivari=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../results-graph/results-graph.component.ts | 40 +++++++++++++++++-- src/app/results/plottable-data.ts | 6 +++ src/app/results/plottable-pab-results.ts | 5 +++ src/app/results/var-results.ts | 10 +++++ 4 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/app/components/results-graph/results-graph.component.ts b/src/app/components/results-graph/results-graph.component.ts index 9cc50d8e7..5cc0a4590 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 d750529b7..a5493b94b 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 b8bfe90c9..27e5685d9 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 95898befc..b01195b15 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) => { -- GitLab