From 3f898adca023a2bfbe46622e752e164f03d6166e Mon Sep 17 00:00:00 2001 From: "mathias.chouet" <mathias.chouet@irstea.fr> Date: Fri, 6 Sep 2019 15:32:33 +0200 Subject: [PATCH] #280 - increase chart axis precision --- .../dialog-edit-param-values.component.ts | 10 +++++++--- .../components/fixedvar-results/results.component.ts | 3 +++ .../pab-profile-graph/pab-profile-graph.component.ts | 4 ++-- .../pab-results/pab-results-table.component.ts | 3 --- .../pab-variable-results-selector.component.ts | 3 --- .../remous-results/remous-results.component.ts | 4 ++-- .../results-graph/results-graph.component.ts | 7 +++---- src/app/formulaire/ngparam.ts | 3 --- src/app/results/plottable-pab-results.ts | 2 ++ src/app/results/var-results.ts | 3 ++- .../internationalisation.service.ts | 1 - 11 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts b/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts index 070a5422d..a660ee797 100644 --- a/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts +++ b/src/app/components/dialog-edit-param-values/dialog-edit-param-values.component.ts @@ -1,11 +1,15 @@ import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material"; import { Inject, Component, OnInit } from "@angular/core"; import { FormBuilder, FormGroup, Validators } from "@angular/forms"; + import { I18nService } from "../../services/internationalisation/internationalisation.service"; import { NgParameter } from "../../formulaire/ngparam"; -import { ParamValueMode, ExtensionStrategy } from "jalhyd"; import { sprintf } from "sprintf-js"; import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; +import { ResultsComponent } from "../fixedvar-results/results.component"; + +import { ParamValueMode, ExtensionStrategy } from "jalhyd"; + import { fv } from "../../util"; @Component({ @@ -107,14 +111,14 @@ export class DialogEditParamValuesComponent implements OnInit { type: "linear", position: "bottom", ticks: { - precision: nDigits + precision: ResultsComponent.CHARTS_AXIS_PRECISION } }], yAxes: [{ type: "linear", position: "left", ticks: { - precision: nDigits + precision: ResultsComponent.CHARTS_AXIS_PRECISION } }] }, diff --git a/src/app/components/fixedvar-results/results.component.ts b/src/app/components/fixedvar-results/results.component.ts index db20c2ec5..9c05df435 100644 --- a/src/app/components/fixedvar-results/results.component.ts +++ b/src/app/components/fixedvar-results/results.component.ts @@ -10,6 +10,9 @@ import { fv } from "../../util"; */ export class ResultsComponent { + /** max number of decimals for auto-adjusting charts axis graduations */ + public static CHARTS_AXIS_PRECISION = 10; + /** tracks the fullscreen state */ public get isFullscreen() { // return (document["fullscreenElement"] !== null); diff --git a/src/app/components/pab-profile-graph/pab-profile-graph.component.ts b/src/app/components/pab-profile-graph/pab-profile-graph.component.ts index 92a5b9979..3ea15a075 100644 --- a/src/app/components/pab-profile-graph/pab-profile-graph.component.ts +++ b/src/app/components/pab-profile-graph/pab-profile-graph.component.ts @@ -73,7 +73,7 @@ export class PabProfileGraphComponent extends ResultsComponent { type: "linear", position: "bottom", ticks: { - precision: nDigits + precision: ResultsComponent.CHARTS_AXIS_PRECISION }, scaleLabel: { display: true, @@ -84,7 +84,7 @@ export class PabProfileGraphComponent extends ResultsComponent { type: "linear", position: "left", ticks: { - precision: nDigits + precision: ResultsComponent.CHARTS_AXIS_PRECISION }, scaleLabel: { display: true, diff --git a/src/app/components/pab-results/pab-results-table.component.ts b/src/app/components/pab-results/pab-results-table.component.ts index d17b83a56..13ca9f097 100644 --- a/src/app/components/pab-results/pab-results-table.component.ts +++ b/src/app/components/pab-results/pab-results-table.component.ts @@ -5,7 +5,6 @@ import { CloisonAval, Result } from "jalhyd"; import * as XLSX from "xlsx"; import { PabResults } from "../../results/pab-results"; -import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; import { ResultsComponent } from "../fixedvar-results/results.component"; import { fv } from "../../util"; @@ -32,7 +31,6 @@ export class PabResultsTableComponent extends ResultsComponent { table: ElementRef; constructor( - protected appSetupService: ApplicationSetupService, protected intlService: I18nService ) { super(); @@ -65,7 +63,6 @@ export class PabResultsTableComponent extends ResultsComponent { && ! this._pabResults.hasOnlyErrors() ) { const pr = this._pabResults; - const nDigits = this.appSetupService.displayDigits; // when a parameter is variating, index of the variating parameter // values to build the data from const vi = pr.variableIndex; diff --git a/src/app/components/pab-results/pab-variable-results-selector.component.ts b/src/app/components/pab-results/pab-variable-results-selector.component.ts index 799cc5267..007aa25c3 100644 --- a/src/app/components/pab-results/pab-variable-results-selector.component.ts +++ b/src/app/components/pab-results/pab-variable-results-selector.component.ts @@ -2,7 +2,6 @@ import { Component, Output, EventEmitter } from "@angular/core"; import { PabResults } from "../../results/pab-results"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; -import { ApplicationSetupService } from "../../services/app-setup/app-setup.service"; import { fv } from "../../util"; @Component({ @@ -30,7 +29,6 @@ export class PabVariableResultsSelectorComponent { constructor( protected intlService: I18nService, - protected appSetupService: ApplicationSetupService ) { this._selectedValue = 0; } @@ -41,7 +39,6 @@ export class PabVariableResultsSelectorComponent { if (this._pabResults) { // pre-extract variable parameters values this.varValues = []; - const nDigits = this.appSetupService.displayDigits; // find longest list this.size = 0; for (let i = 0; i < this._pabResults.variatedParameters.length; i++) { diff --git a/src/app/components/remous-results/remous-results.component.ts b/src/app/components/remous-results/remous-results.component.ts index df5678887..d349db0e5 100644 --- a/src/app/components/remous-results/remous-results.component.ts +++ b/src/app/components/remous-results/remous-results.component.ts @@ -604,7 +604,7 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck offsetGridLines: true }, ticks: { - precision: nDigits, + precision: ResultsComponent.CHARTS_AXIS_PRECISION, callback: function(value, index, values) { return fv(Number(value)); } @@ -644,7 +644,7 @@ export class RemousResultsComponent extends ResultsComponent implements DoCheck labelString: this.uitextAbscisse }, ticks: { - precision: nDigits, + precision: ResultsComponent.CHARTS_AXIS_PRECISION, callback: function(value, index, values) { return fv(Number(value)); } diff --git a/src/app/components/results-graph/results-graph.component.ts b/src/app/components/results-graph/results-graph.component.ts index 96c35127a..43933e81e 100644 --- a/src/app/components/results-graph/results-graph.component.ts +++ b/src/app/components/results-graph/results-graph.component.ts @@ -239,7 +239,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont offsetGridLines: true }, ticks: { - precision: nDigits, + precision: ResultsComponent.CHARTS_AXIS_PRECISION, callback: function(value, index, values) { return fv(Number(value)); } @@ -322,7 +322,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont type: "linear", position: "bottom", ticks: { - precision: nDigits + precision: ResultsComponent.CHARTS_AXIS_PRECISION }, scaleLabel: { display: true, @@ -333,7 +333,7 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont type: "linear", position: "left", ticks: { - precision: nDigits + precision: ResultsComponent.CHARTS_AXIS_PRECISION }, scaleLabel: { display: true, @@ -401,7 +401,6 @@ export class ResultsGraphComponent extends ResultsComponent implements AfterCont const ret: IYSeries[] = []; const palette = ResultsComponent.distinctColors; const xSeries = this._results.getValuesSeries(this.chartX); - const nDigits = this.appSetup.displayDigits; let symbols: string[]; // whole family of variables => multiple series (should only happen with VarResults) diff --git a/src/app/formulaire/ngparam.ts b/src/app/formulaire/ngparam.ts index a58d5ff42..136bbcaeb 100644 --- a/src/app/formulaire/ngparam.ts +++ b/src/app/formulaire/ngparam.ts @@ -42,7 +42,6 @@ export class NgParameter extends InputField implements Observer { public static preview(p: ParamDefinition, compact: boolean = false): string { let valuePreview: string; const i18n = ServiceFactory.instance.i18nService; - const nDigits = ServiceFactory.instance.applicationSetupService.displayDigits; switch (p.valueMode) { case ParamValueMode.SINGLE: @@ -101,7 +100,6 @@ export class NgParameter extends InputField implements Observer { public static linkedValuePreview(ref: LinkedValue): string { let valuePreview: string; const i18n = ServiceFactory.instance.i18nService; - const nDigits = ServiceFactory.instance.applicationSetupService.displayDigits; if (ref.isParameter()) { const targetParam = (ref.element as ParamDefinition); @@ -201,7 +199,6 @@ export class NgParameter extends InputField implements Observer { // undefined si on clique en dehors du select après l'avoir ouvert (cad sans avoir fait de sélection) // et au même niveau, cad à côté du bouton et non à côté du menu déroulant if (m !== undefined && this._paramDef.valueMode !== m) { - const nDigits = ServiceFactory.instance.applicationSetupService.displayDigits; this.unlinkParameter(); this._paramDef.valueMode = m; this.notifyObservers({ diff --git a/src/app/results/plottable-pab-results.ts b/src/app/results/plottable-pab-results.ts index f697ecac0..8f340a954 100644 --- a/src/app/results/plottable-pab-results.ts +++ b/src/app/results/plottable-pab-results.ts @@ -3,6 +3,8 @@ import { PabResults } from "./pab-results"; import { GraphType } from "./graph-type"; import { ServiceFactory } from "../services/service-factory"; +import { ParamDefinition } from "jalhyd"; + export class PlottablePabResults implements PlottableData { public graphType: GraphType = GraphType.Scatter; diff --git a/src/app/results/var-results.ts b/src/app/results/var-results.ts index a3823065c..d2a451ee7 100644 --- a/src/app/results/var-results.ts +++ b/src/app/results/var-results.ts @@ -1,7 +1,8 @@ +import { ResultElement, ParamFamily, ParamDefinition } from "jalhyd"; + import { CalculatorResults } from "./calculator-results"; import { CalculatedParamResults } from "./param-calc-results"; import { NgParameter } from "../formulaire/ngparam"; -import { ResultElement, ParamFamily } from "jalhyd"; import { ServiceFactory } from "../services/service-factory"; import { PlottableData } from "./plottable-data"; import { GraphType } from "./graph-type"; diff --git a/src/app/services/internationalisation/internationalisation.service.ts b/src/app/services/internationalisation/internationalisation.service.ts index 063fd0a3a..fbf1226a5 100644 --- a/src/app/services/internationalisation/internationalisation.service.ts +++ b/src/app/services/internationalisation/internationalisation.service.ts @@ -197,7 +197,6 @@ export class I18nService extends Observable implements Observer { if (match > -1) { return this.localizeText(`INFO_${label.substring(match).toUpperCase()}_${value}`); } - const nDigits = this.applicationSetupService.displayDigits; return fv(value); } -- GitLab