changeset 1054:9bd4f82fcd8d crossprofile

display additional profile
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 25 Oct 2018 15:01:59 +0200
parents 82ae9cb56982
children 28eb62f7c676
files client/src/fairway/Fairwayprofile.vue
diffstat 1 files changed, 40 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/fairway/Fairwayprofile.vue	Thu Oct 25 13:11:09 2018 +0200
+++ b/client/src/fairway/Fairwayprofile.vue	Thu Oct 25 15:01:59 2018 +0200
@@ -79,7 +79,7 @@
  */
 import * as d3 from "d3";
 import { mapState } from "vuex";
-import { displayInfo } from "../application/lib/errors.js";
+import { displayError } from "../application/lib/errors.js";
 
 const GROUND_COLOR = "#4A2F06";
 
@@ -149,31 +149,33 @@
   },
   methods: {
     selectAdditionalSurveyData() {
-      if (!this.additionalSurvey || this.wait) return;
-      //   this.$store
-      //     .dispatch("fairwayprofile/loadProfile", this.additionalSurvey)
-      //     .then(() => {
-      //       this.wait = false;
-      //       this.drawDiagram();
-      //     })
-      //     .catch(error => {
-      //       this.wait = false;
-      //       let status = "ERROR";
-      //       let data = error;
-      //       const response = error.response;
-      //       if (response) {
-      //         status = response.status;
-      //         data = response.data;
-      //       }
-      //       displayError({
-      //         title: "Backend Error",
-      //         message: `${status}: ${data.message || data}`
-      //       });
-      //     });
-      displayInfo({
-        title: "Not Implemented",
-        message: `Currently under development`
-      });
+      if (
+        !this.additionalSurvey ||
+        this.wait ||
+        this.currentProfile[this.additionalSurvey]
+      ) {
+        this.drawDiagram();
+        return;
+      }
+      this.$store
+        .dispatch("fairwayprofile/loadProfile", this.additionalSurvey)
+        .then(() => {
+          this.wait = false;
+        })
+        .catch(error => {
+          this.wait = false;
+          let status = "ERROR";
+          let data = error;
+          const response = error.response;
+          if (response) {
+            status = response.status;
+            data = response.data;
+          }
+          displayError({
+            title: "Backend Error",
+            message: `${status}: ${data.message || data}`
+          });
+        });
     },
     drawDiagram() {
       const chartDiv = document.querySelector(".fairwayprofile");
@@ -206,18 +208,20 @@
         height,
         width,
         color: GROUND_COLOR,
-        strokeColor: "black"
+        strokeColor: "black",
+        opacity: 1
       });
       if (additionalData) {
         this.drawProfile({
           graph,
           xScale,
           yScaleRight,
-          additionalData,
+          currentData: additionalData,
           height,
           width,
-          color: "green",
-          strokeColor: "green"
+          color: GROUND_COLOR,
+          strokeColor: "#943007",
+          opacity: 0.6
         });
       }
       this.drawLabels({
@@ -341,7 +345,8 @@
       currentData,
       height,
       color,
-      strokeColor
+      strokeColor,
+      opacity
     }) {
       for (let part of currentData) {
         let profileLine = d3
@@ -367,6 +372,8 @@
           .attr("fill", color)
           .attr("stroke", color)
           .attr("stroke-width", 3)
+          .attr("stroke-opacity", opacity)
+          .attr("fill-opacity", opacity)
           .attr("d", profileArea);
         graph
           .append("path")
@@ -376,6 +383,8 @@
           .attr("stroke-linejoin", "round")
           .attr("stroke-linecap", "round")
           .attr("stroke-width", 3)
+          .attr("stroke-opacity", opacity)
+          .attr("fill-opacity", opacity)
           .attr("d", profileLine);
       }
     }