From 4cbfda52e0ca721c4f9f37ab3c704058fe02bcbd Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Mon, 9 Sep 2019 17:04:01 +0200 Subject: [PATCH] Fix #118 - simple plot (dots) chart type --- .../fixedvar-results/results.component.ts | 2 +- .../results-graph/graph-type.component.ts | 3 ++- .../results-graph/results-graph.component.ts | 23 +++++++++++++++++-- src/app/results/graph-type.ts | 4 ++-- src/locale/messages.en.json | 1 + src/locale/messages.fr.json | 1 + 6 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/app/components/fixedvar-results/results.component.ts b/src/app/components/fixedvar-results/results.component.ts index 9c05df435..748816761 100644 --- a/src/app/components/fixedvar-results/results.component.ts +++ b/src/app/components/fixedvar-results/results.component.ts @@ -43,7 +43,7 @@ export class ResultsComponent { */ public static get distinctColors(): string[] { return [ - "#4363d8", // blue + "#003A80", // Irstea "marine", replacing the suggested "#4363d8" (blue) "#f58231", // orange "#3cb44b", // green "#e6194B", // red diff --git a/src/app/components/results-graph/graph-type.component.ts b/src/app/components/results-graph/graph-type.component.ts index 2895abe75..5d70501b0 100644 --- a/src/app/components/results-graph/graph-type.component.ts +++ b/src/app/components/results-graph/graph-type.component.ts @@ -11,7 +11,7 @@ import { GraphType } from "../../results/graph-type"; ] }) export class GraphTypeSelectComponent implements IObservable { - private _entries: GraphType[] = [GraphType.Histogram, GraphType.Scatter]; + private _entries: GraphType[] = [ GraphType.Histogram, GraphType.Dots, GraphType.Scatter ]; private _entriesLabels: string[] = []; private _selected: GraphType; @@ -25,6 +25,7 @@ export class GraphTypeSelectComponent implements IObservable { this._observable = new Observable(); this._entriesLabels = [ this.intlService.localizeText("INFO_PARAMFIELD_GRAPH_TYPE_HISTOGRAM"), + this.intlService.localizeText("INFO_PARAMFIELD_GRAPH_TYPE_DOTS"), "XY" ]; } diff --git a/src/app/components/results-graph/results-graph.component.ts b/src/app/components/results-graph/results-graph.component.ts index 589fdac1f..420583a33 100644 --- a/src/app/components/results-graph/results-graph.component.ts +++ b/src/app/components/results-graph/results-graph.component.ts @@ -176,6 +176,11 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont this.generateBarGraph(); break; + case GraphType.Dots: + this.graph_type = "line"; + this.generateLineGraph(); + break; + default: this.graph_type = "scatter"; this.generateScatterGraph(); @@ -265,7 +270,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont const lines: string[] = []; const nbLines = that._results.getVariatingParametersSymbols().length; for (const v of that._results.getVariatingParametersSymbols()) { - const series = that._results.getValuesSeries[0](v); + const series = that._results.getValuesSeries(v); const line = v + " = " + fv(series[tooltipItem.index]); if (v === this.chartX) { if (nbLines > 1) { @@ -285,11 +290,25 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont labels: labs, datasets: [{ label: "", - data: dat + data: dat, + backgroundColor: "rgba(0, 58, 128, 0.5)", // ResultsComponent.distinctColors[0] with transparency + showLine: "true" }] }; } + /** + * génère les données d'un graphe de type "line" + */ + private generateLineGraph() { + // same as bar graph (histogram) + this.generateBarGraph(); + // override style + this.graph_data.datasets[0].backgroundColor = "rgba(0,0,0,0)"; // fill color under the line : transparent + this.graph_data.datasets[0].borderColor = ResultsComponent.distinctColors[0]; + this.graph_data.datasets[0].showLine = false; + } + /** * génère les données d'un graphe de type "scatter" */ diff --git a/src/app/results/graph-type.ts b/src/app/results/graph-type.ts index cf83fc76e..67d5dcf57 100644 --- a/src/app/results/graph-type.ts +++ b/src/app/results/graph-type.ts @@ -8,9 +8,9 @@ export enum GraphType { Histogram, /** - * points indépendants reliés par une courbe + * points indépendants */ - HistoLine, + Dots, /** * graphe XY classique diff --git a/src/locale/messages.en.json b/src/locale/messages.en.json index 897cd44e4..12c2c290e 100644 --- a/src/locale/messages.en.json +++ b/src/locale/messages.en.json @@ -336,6 +336,7 @@ "INFO_PARAMFIELD_GRAPH_SELECT_X_AXIS": "Variable for X axis", "INFO_PARAMFIELD_GRAPH_SELECT_Y_AXIS": "Variable for Y axis", "INFO_PARAMFIELD_GRAPH_TYPE_HISTOGRAM": "Histogram", + "INFO_PARAMFIELD_GRAPH_TYPE_DOTS": "Plot", "INFO_PARAMFIELD_GRAPH_TYPE": "Graph type", "INFO_PARAMFIELD_IN_CALCULATION_INITIAL_VALUE": "initial value", "INFO_PARAMFIELD_IN_CALCULATION": "In calculation", diff --git a/src/locale/messages.fr.json b/src/locale/messages.fr.json index 504fc9bbf..0afc52799 100644 --- a/src/locale/messages.fr.json +++ b/src/locale/messages.fr.json @@ -335,6 +335,7 @@ "INFO_PARAMFIELD_GRAPH_SELECT_X_AXIS": "Variable en abscisse", "INFO_PARAMFIELD_GRAPH_SELECT_Y_AXIS": "Variable en ordonnée", "INFO_PARAMFIELD_GRAPH_TYPE_HISTOGRAM": "Histogramme", + "INFO_PARAMFIELD_GRAPH_TYPE_DOTS": "Points", "INFO_PARAMFIELD_GRAPH_TYPE": "Type de graphe", "INFO_PARAMFIELD_IN_CALCULATION_INITIAL_VALUE": "valeur initiale", "INFO_PARAMFIELD_IN_CALCULATION": "En calcul", -- GitLab