changeset 3942:cd8ba6599a99

fairway_profile: remove dependency on local state variable
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 12 Jul 2019 11:20:09 +0200
parents 7b3935a8d9ee
children 3c468ed76daf
files client/src/components/fairway/Fairwayprofile.vue
diffstat 1 files changed, 10 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/Fairwayprofile.vue	Fri Jul 12 11:02:46 2019 +0200
+++ b/client/src/components/fairway/Fairwayprofile.vue	Fri Jul 12 11:20:09 2019 +0200
@@ -168,12 +168,6 @@
       resizeListenerFunction: null,
       width: null,
       height: null,
-      margin: {
-        top: 20,
-        right: 80,
-        bottom: 60,
-        left: 80
-      },
       form: {
         template: null
       },
@@ -419,11 +413,12 @@
       const height = dimensions.mainHeight;
       const currentData = this.currentData;
       const additionalData = this.additionalData;
-      const { xScale, yScaleRight, graph } = this.generateScalesAndGraph(
+      const { xScale, yScaleRight, graph } = this.generateScalesAndGraph({
         svg,
         height,
-        width
-      );
+        width,
+        dimensions
+      });
       this.drawWaterlevel({ graph, xScale, yScaleRight, height });
       this.drawLabels({ graph, dimensions });
       if (currentData) {
@@ -530,7 +525,7 @@
         ])
         .text("Width [m]");
     },
-    generateScalesAndGraph(svg, height, width) {
+    generateScalesAndGraph({ svg, height, width, dimensions }) {
       let xScale = d3
         .scaleLinear()
         .domain([0, this.totalLength])
@@ -565,7 +560,11 @@
         .append("g")
         .attr(
           "transform",
-          "translate(" + this.margin.left + "," + this.margin.top + ")"
+          "translate(" +
+            dimensions.mainMargin.left +
+            "," +
+            dimensions.mainMargin.top +
+            ")"
         );
       graph
         .append("g")