changeset 3327:7ab8a176db92

available_fairway_depth: adjust scale according to selected timerange
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 20 May 2019 12:41:57 +0200
parents 98ce6d101e01
children 91a3f6835f3d
files client/src/components/fairway/AvailableFairwayDepth.vue
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepth.vue	Mon May 20 12:32:10 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepth.vue	Mon May 20 12:41:57 2019 +0200
@@ -75,6 +75,7 @@
 import { pdfgen } from "@/lib/mixins";
 import { HTTP } from "@/lib/http";
 import { displayError } from "@/lib/errors";
+import { FREQUENCIES } from "@/store/fairwayavailability";
 
 const hoursInDays = x => x / 24;
 
@@ -178,6 +179,14 @@
       "legend"
     ]),
     ...mapState("user", ["user"]),
+    frequencyToRange() {
+      const frequencies = {
+        [FREQUENCIES.MONTHLY]: [-33, 33],
+        [FREQUENCIES.QUARTERLY]: [-93, 93],
+        [FREQUENCIES.YEARLY]: [-370, 370]
+      };
+      return frequencies[this.frequency];
+    },
     fromDate() {
       return this.from;
     },
@@ -406,7 +415,7 @@
       });
       this.yScale = d3
         .scaleLinear()
-        .domain([-33, 33])
+        .domain(this.frequencyToRange)
         .range([this.dimensions.mainHeight - 30, 0]);
       d3.select(".diagram-container svg").remove();
       this.generateDiagramContainer();